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

From |
David Kantor <dkantor@jhu.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: calculating group means |

Date |
Thu, 25 Jul 2002 18:39:53 -0400 |

At 04:40 PM 7/25/2002 -0400, Gayatri Koolwal. wrote:

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?As Marcela Perticara indicated, you can use egen ... mean ... by(householdid)

But note that there are two possibilities. If you want to take a household mean and spread it onto your set of individuals (by household), then use egen ... mean ... by(householdid). But if you want to reduce to a set of households (i.e., one observation per household), then -collapse- is more convenient. (You could still use egen ... mean, but you would then want to reduce it to one representative per household.)

I hope this helps.

-- David

David Kantor

Institute for Policy Studies

Johns Hopkins University

dkantor@jhu.edu

410-516-5404

*

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

- Prev by Date:
**st: Re: calculating group means** - Next by Date:
**st: Update to decomp** - Previous by thread:
**st: Re: calculating group means** - Next by thread:
**st: macro basics** - Index(es):

© Copyright 1996–2016 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |