Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: assigning characteristics of one person to multiple observations by group


From   "Salvati, Jean" <[email protected]>
To   <[email protected]>
Subject   st: RE: assigning characteristics of one person to multiple observations by group
Date   Wed, 22 Feb 2006 15:48:32 -0500

You can do the following:

gen age_hh_tmp = AGE if PARENT == "HH" 
bysort id: egen age_hh = mean(age_hh_tmp)

Jean Salvati

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of 
> Scott Cunningham
> Sent: Wednesday, February 22, 2006 3:02 PM
> To: [email protected]
> Subject: st: assigning characteristics of one person to 
> multiple observations by group
> 
> I have the following:
> 
> ID		Name			PARENT		AGE
> 1		Bryan			HH			
> 	45
> 1		WIll				son		
> 		10
> 1		Lucy			mom			30
> 2		Scott			HH			
> 	30
> 2		Paige			mom			31
> 2		Miles			son			
> 	4
> 
> I need to create a variable ("age_HH") which will equal the 
> age of the head of household ("HH").  I then need to make 
> everyone of the same family ("ID") have that value.  Is it 
> sufficient to do the
> following:
> 
> . bysort id: gen age_hh=age if parent==hh
> 
> 
> 
> *
> *   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/
> 

*
*   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