st: Calculating means to use in later regressions

Hello Stata users,
I have a variable called Country (list of county names) and another called
period (1 to 4 representing the decades 1960s through 1990s); and yet
another called RealGDP (annual realGDP per capita by country). How can
I generate a the mean of each period for each country? I would ideally like
to end up with a new variable which can be used to run cross-country
regression on the decade aveages.
. collapse (mean) RealGDP, by(Country period)
type mismatch
r(109);
is clearly not working, nor is:
. by period, sort: gen AveRealGDP=sum(RealGDP)/sum(RealGDP~=.)
type mismatch
r(109);
. for Country: egen RealGDPbar = mean(RealGDP), by period
"Country" invalid list type
r(198);
So I'm stuck. Can anyone help?
Best regards,
Joel Clovis
Joel Clovis
*
* 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/