Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Re: Assigning sex by order of birth
From
Cinzia Rienzo <[email protected]>
To
Cinzia Rienzo <[email protected]>
Subject
st: Re: Assigning sex by order of birth
Date
Mon, 15 Mar 2010 09:57:49 +0000 (GMT)
Thanks to Nick and Martin for your help and explanations.
About the twins code in fact the rank variable will look like 1.5 or
2.5 when there are twins.
Best
Cinzia
Cinzia Rienzo wrote:
>Dear All,
>
>I have some difficulties in creating variables for children in the
>family accounting for their sex and order of birth; in other words I
>want to create the following variables:
>“Boy1st” if First child born is male;
>“Girl1st” if First child born is female
>“boy2nd” if Second child born is male
>“girl2nd” if Second child born is female and so on.
>
>I tried with the “egen rank” to create order using the reverse of the
>age of children in families:
>bysort year family: g agechil=age if member ==”child”
>bysort year family: g agechil reversed= agechil*-1
>bysort year serial : egen rank_var = rank(agechil reversed)
>
> But when I Tab the rank it gives me: 1; 1.5 ; 2; 2.5; 3; 3.5…..
>My question is: How can I assign the sex by order of birth in families
>using the rank given that the age of first child and numbers of
>children vary by families?
>As in the example below the first child in family 1 is 12 year old and
>the first child in family 2 is 9.
>
>
>Family age of child sex
> 1 12 male
> 1 5 female
> 1 2 female
> 2 9 female
> 2 7 female
> 2 4 male
> 2 1 female
>
>
>I appreciate any helps and/or suggestions.
>
>Best
>
>Cinzia
>
>------
>Cinzia
>
------
Cinzia
*
* 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/