Dear Statalisters,
I'd like to convert a panel data set with annual country obs to one of
decadal country averages, excluding those decadal averages for which 5 or
more observations per country are missing within a decade.
My first idea was to use a two step procedure along the lines of:
1. Run:
collapse (mean) GDP (count) GDP , by(country decade)
this should give me a) the decadal averages I want and b) the number of
non-missing obs used to compute each of these decadal averages.
2. replace mean_GDP=. if count_GDP<5 (or whatever STATA will call these vars
saving the means & counting the non-missing obs)
this should set to missing those decadal averages for which 5 or more
observations per country were missing within each decade.
However, trying this I get the following error message:
. collapse (count) GDP (mean) GDP, by(sftgcode decade)
error:
GDP = (count) GDP
GDP = (mean) GDP
name conflict
r(198);
Does this mean that I cannot get means and counts for the same variable at
the same time when using collapse? Moreover, is there any way to directly
aggregate annual obs to decadal country averages while omitting those
averages for which a pre-specified number of obs. is missing per country?
I wasn't able to find any solution to this on the archives, although I
assume it's a rather common problem. Thank you very much for your help.
Best,
Jens Hainmueller
*
* 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/