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
Mitch Abdon <[email protected]>
To
[email protected]
Subject
Re: st: generating parent variable in child level data
Date
Mon, 8 Nov 2010 10:55:29 +0800
Hi. Here is one way of doing this:
gen age_mother=.
gen age_father=.
gen educ_mother=.
gen educ_father=.
levelsof hhid, local(levels)
foreach i of local levels{
qui: sum age if relation=="mother" & hhid==`i'
replace age_mother=r(mean) if hhid==`i'
qui: sum age if relation=="father" & hhid==`i'
replace age_father=r(mean) if hhid==`i'
qui: sum education if relation=="mother" & hhid==`i'
replace educ_mother=r(mean) if hhid==`i'
qui: sum education if relation=="father" & hhid==`i'
replace educ_father=r(mean) if hhid==`i'
}
if you don't need the lines for 'mother' and 'father' , you can just drop them
On Mon, Nov 8, 2010 at 9:58 AM, Shikha Sinha <[email protected]> wrote:
> Dear all,
>
> I have a household level data set in which each household has father,
> mother, and child level data as row, something as the following:
>
> hhid relation age education
> 1 father 40 8
> 1 mother 38 3
> 1 son 18 4
> 1 son 15 2
> 1 daughter 12 2
>
> I wish to generate parent level variable (age, education) for every
> children in the same household. Please suggest.
>
> Thanks,
> Shikha
> *
> * 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/
>
--
Best,
Mitch
------------------------------------------------------------------
Arnelyn Abdon
Consultant
Central and West Asia Department
Asian Development Bank
Philippines
http://statadaily.wordpress.com
------------------------------------------------------------------
*
* 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/