
From  Ryan Herzog <rherzog@uoregon.edu> 
To  statalist@hsphsun2.harvard.edu 
Subject  Re: st: How to calculate mean of other individuals on the same group 
Date  Tue, 13 Feb 2007 21:04:24 0800 
Quang Nguyen wrote:
Dear all,Generate the sum of each group: egen sum_var = sum(X), by(group)
A simplified version of my data looks as follows:
ID Group X
1 a 5
2 a 7
3 a 9
4 a 8
5 b 3
6 b 4
7 b 9
..........................
I would like to generate a new variable whose value is the average of
other individual in the same group as the concerned individual. For
example, for the first individual (ID=1), this will be: (7+9+8)/3= 8.
For the 6th individual, this will be (3+9)/2=6 and so on.
I would highly appreciate if someone could suggest me a solution for this.
Thanks and Have A Great Day!
Sincerely yours,
Quang
*
* 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–2017 StataCorp LLC  Terms of use  Privacy  Contact us  What's new  Site index 