Bookmark and Share

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]

Re: st: generating parent variable in child level data


From   Eric Booth <[email protected]>
To   "<[email protected]>" <[email protected]>
Subject   Re: st: generating parent variable in child level data
Date   Mon, 8 Nov 2010 18:22:14 +0000

<>

One issue would be if you've got multiple fathers or mothers listed for a child/HHID (both my post and Nick's post mention this potential issue...plus, Nick shows you how to count the parents to check for this).
The problem is that -egen, total()- will add up the ages for the two fathers, so using earlier example,  you'll get the value of 62 for HHID 2 (see below).  


*****!

clear
inp hhid   str10(relation)    age    education
1   father      40        8
1   mother    38        3
1   son         18       4
1   son         15       2
1   daughter   12      2
2   father  30  9
2   son     5   2
2   father  32  12
end

g fage=age if relation=="father"
bys hhid: egen fage1=total(fage)
li
*****!

- Eric

__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]


On Nov 8, 2010, at 12:09 PM, Shikha Sinha wrote:

> Thanks everyone for your advice. I tried the following and it worked.
> Do you see any probelm in the follwoing approach:
> 
> g fage=age if relation=="father"
> bys hhid: egen fage1=total(fage)
> 
> Thanks,
> Shikha
> 
> On Mon, Nov 8, 2010 at 7:15 AM, Nick Cox <[email protected]> wrote:
>> This crossed with Eric Booth's solution, which in a way is about half-way between mine and Mitch Abdon's.
>> 
>> In my solution, the age for the mother, for example, is recorded for the mother herself and also for the father. Values in such observations can be ignored if of no interest or set to missing afterwards.
>> 
>> For more on -cond()- if desired, see
>> 
>> SJ-5-3  pr0016  . . Depending on conditions: a tutorial on the cond() function
>>        . . . . . . . . . . . . . . . . . . . . . . .  D. Kantor and N. J. Cox
>>        Q3/05   SJ 5(3):413--420                                 (no commands)
>>        tutorial on the cond() function
>> 
>> Nick
>> [email protected]
> 
<snip>



*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index