I have a panel of 32 countries and 16 years. I have used Excel to
calculate 4-year averages for each countries. Is it possible to do
this in Stata? So far, I have only found commands for calculating
moving averages, which is NOT what I want.
Three ways:
define a group variable that identifies quadrennia, and egen mean from
that.
e.g.
bys country: g quad = int((_n-1)/4)+1
egen qavg =mean(data), by(cty3 quad)
use mvsumm which does calculate overlapping stats and throw away the
values for years 1,2,3, or set them equal to the value for period 4
(_n==_N in a by-group).
define the group variable as above and collapse on it; that changes
your data set into 32 countries and 4 quadrennia, if that is what you
want.