st: period averages

 From Kit Baum <[email protected]> To [email protected] Subject st: period averages Date Thu, 28 Jul 2005 08:43:33 -0400

Joana said

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

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.

Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html

*
* 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/