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

st: Creating a new variable using household level data


From   Ali Murat Berker <[email protected]>
To   [email protected]
Subject   st: Creating a new variable using household level data
Date   Sun, 13 Feb 2005 23:40:19 +0200

Hello all,
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.
Best Regards.
Ali M Berker
*
*   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