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

st: RE: mean of variable


From   "Stephen P Jenkins" <[email protected]>
To   <[email protected]>
Subject   st: RE: mean of variable
Date   Thu, 29 Jan 2004 08:57:39 -0000

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of 
> [email protected]
> Sent: 29 January 2004 08:46
> To: [email protected]
> Subject: st: mean of variable
> 
> 
> Hi All,
> 
> I try to generate a new variable out of the mean of another 
> variable (for each person)! Is there an easy way to solve 
> this problem?

Example:

Suppose you have data for individuals, and also know which household
they belong to, and the age of each person in the household. You want to
attribute to each person the mean age among the individuals of the
household to which he belongs.
	by hh_id: egen mean_age = mean(age)

More generally, look through -egen- in the manual; read about "by group"
operations in the User Guide, and also look through the Stata FAQs

Stephen
-------------------------------------------------------------
Professor Stephen P. Jenkins <[email protected]>
Institute for Social and Economic Research
University of Essex, Colchester CO4 3SQ, U.K.
Tel: +44 1206 873374.  Fax: +44 1206 873151.
http://www.iser.essex.ac.uk   

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