[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Re: calculating group means
check the egen package, specifically the mean function
and use it with the by command.
sort hh_id /*hoursehold identifier*/
by hh_id: gen newvar=mean(x2)
----- Original Message -----
From: "Gayatri Koolwal" <firstname.lastname@example.org>
Sent: Thursday, July 25, 2002 4:40 PM
Subject: st: calculating group means
> I have a data set of individuals who belong to different households, each
> with a value of a variable x2. For each household, I would like to create
> a new variable that is the mean of x2 for the individuals in that
> household. Would anyone be able to help me with the procedure for
> this? Do I need to collapse the data set first somehow?
> Thank you very much!
> Gayatri Koolwal.
> * 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/
Universidad Alberto Hurtado
* For searches and help try: