Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Creating a new variable using household level data


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Creating a new variable using household level data
Date   Sun, 13 Feb 2005 22:17:08 -0000

The fathers' and mothers' ages are 

. bysort hhid : gen fatherage = age[Father] 

. by hhid : gen motherage = age[Mother] 

If there's at least one father present, a dummy 
for at least one father present is 

bysort hhid (Father) : gen any_father_present = Father[1] < . 

or 

egen any_father_present = max(Father < .), by(hhid) 

using methods in the FAQs in this territory 
publicised only last week (see Friedrich 
Huebler's posting for the URLs).  

If the dummy is for "is this child's father 
present?" that appears to be just 

gen my_father_present = father < .  

The commands for mothers are naturally similar. 

This procedure would seem to leave orphans. 

Nick 
[email protected] 

Ali Murat Berker

> I am working on several Demographic and Health Surveys. I converted 
> the data from wide to long form by using reshape command. I  obtained
> the data presented below.
> * Label list for relhd: relation to head
>           1 head
>            2 wife or husband
>            3 son/daughter
>            4 son/daughter-in-law
>            5 grandchild
>            6 parent
>            7 parent-in-law
>            8 brother/sister
>            9 co-spouse
>           10 other relative
>           11 adopted/foster child
>           12 not related
>           98 dk;
>  * Label list for gender:
>             1 male
>             2 female;
> Table 1
> hhid   linenumber   Relhd        age       gender   Father's line
> number  Mother' s line
> 11	1	1	42	1	.                       .
> 11	2	2	37	2	.                       .
> 11	3	3	16	2	.                       .
> 11	4	3	10	2	2                       1
> 11	5	3	5	1	2                       1
> 16	1	1	53	1	.                        .
> 16	2	2	53	2	.                        .
> 16	3	3	31	1	.                        .
> 16	4	4	30	2	.                        .
> 16	5	5	6	1	4                       3
> 16	6	3	25	1	.                        .
> 34	1	1	52	1	.                        .
> 34	2	2	48	2	.                        .
> 34	3	3	24	1	.                        .
> 34	4	3	16	1	.                        .
> 34	5	3	13	1	2                       1
> 34	6	4	29	2	.                        .
> 34	7	5	3	2	6                       3
> 
> Using the data in Table 1, I want to create four new variables: a
> dummy variable for a being father, a dummy variable for  being a
> mother, father's age, mother's age.
> I just can't figure out how to use father's and mother' s line number
> to obtain these varaibles.  If there were only a mother and a father,
> and children in the household, it would be very easy to create dummy
> variables for being a father and mother. One simply needs to do:
> * Create a dummy variable for the presence of the father in a 
> household;
>  gen father=0;
>  replace father=(gender==1 & relhd==1) | (gender==1 & hmemrelhdw==2);
> Howewer, the data suggest that more than one famliles may live in the
> same houesehold. Then, two command lines stated above are not able to
> produce  the desired outcomes.
> How can I do this task? Any help are more than welcome.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index