[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
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)
is clearly not working, nor is:
. by period, sort: gen AveRealGDP=sum(RealGDP)/sum(RealGDP~=.)
. for Country: egen RealGDPbar = mean(RealGDP), by period
"Country" invalid list type
So I'm stuck. Can anyone help?
* For searches and help try: