<>
"Could you suggest a simple way of doing this?"
Taking a cue from Nick`s FAQ cited earlier:
*************
clear*
set obs 40
gen country=_n
gen quarter=quarterly("1990:1", "YQ")
expand 68
bys country: /*
*/ replace quarter=quarter+_n-1
format quarter %tq
gen icrg=rnormal(10,100)
//calculate mean
bys quarter: egen totalicrg= /*
*/ total(icrg)
//divide by # of countries-1
gen mymean=(totalicrg-icrg)/39
//10 random checks...
forv i=1/10{
local a= 1+int(`c(N)'*runiform())
l country quarter mymean in `a'
su icrg if quarter==quarter[`a'] /*
*/ & country!=country[`a']
}
*************
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von kokootchke
Gesendet: Freitag, 23. Oktober 2009 07:39
An: statalist
Betreff: st: Compute mean for groups leaving one member out
Dear all:
I have a panel dataset of 40 countries at quarterly frequency from 1990:1 to
2006:4. I would like to compute the average of a variable (called icrg) for
all countries in a given time period. My problem is that in doing this
computation, I would like to leave one country out of the calculation.
For example, in period 1990:1 for Mexico, I would like to compute the
average of icrg for ALL other countries in this period EXCLUDING Mexico.
Could you suggest a simple way of doing this?
Thank you very much.
Best,
Adrian
_________________________________________________________________
Windows 7: It helps you do more. Explore Windows 7.
http://www.microsoft.com/Windows/windows-7/default.aspx?ocid=PID24727::T:WLM
TAGL:ON:WL:en-US:WWL_WIN_evergreen3:102009
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/