Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: AW: Is there a command for picking off the lowest values of an Identified group?


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: Is there a command for picking off the lowest values of an Identified group?
Date   Thu, 29 Jul 2010 17:49:54 +0200

<> 



*************
clear*

inp byte Mother_ID str1 Child_ID byte Child_Age
1   a  1
1   b  2
1   c  3
1   d  4
2   e  10
2   f   10
2   g  12
3   h  5
3   i   7
end

bys Mother_ID: egen minagechild=min(Child_Age)

li, noo sepby(Mother_ID)

*************

See NJC`s http://www.stata-journal.com/sjpdf.html?articlenum=pr0004


HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Ian Breunig
Gesendet: Donnerstag, 29. Juli 2010 17:43
An: statalist@hsphsun2.harvard.edu
Betreff: st: Is there a command for picking off the lowest values of an
Identified group?

I want to find the age of the mother's youngest child.

If, for example, I have data as follows:

Mother ID:        Child ID:     Child Age:

1                         a                  1
1                         b                  2
1                         c                  3
1                         d                  4
2                         e                  10
2                         f                   10
2                         g                  12
3                         h                  5
3                         i                   7

Is there a simple command to tell me the youngest age for every Mother
ID or  do I have to use a do loop and if statement to do this?  If so
can anyone help me out with the most efficient way to code the do
loop.

I have used - collapse - and an if statement to count children under a
specified age before but I can't seem to find a command to do what I
want above.

Thanks ahead of time if you can help!

Ian
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index