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

st: Re: calculating group means


From   "Marcela Perticara" <[email protected]>
To   <[email protected]>
Subject   st: Re: calculating group means
Date   Thu, 25 Jul 2002 18:04:05 -0400

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" <[email protected]>
To: <[email protected]>
Sent: Thursday, July 25, 2002 4:40 PM
Subject: st: calculating group means


> Hello,
>
> 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
http://www.uahurtado.cl
*
*   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