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.
It has already been pointed out that you must give different names to your
new variables with this solution.