Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Calculating period averages


From   "Clive Nicholas" <[email protected]>
To   [email protected]
Subject   Re: st: Calculating period averages
Date   Thu, 28 Jul 2005 10:19:28 +0100 (BST)

Joana Quina wrote:

> 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.

Use Kit Baum and Nick Cox's -mvsumm- routine (downloadable from SSC),
together with its -stat()- and -window()- options, which does precisely
what you want to do. An example:

. ssc install mvsumm

. webuse grunfeld, clear

. mvsumm invest, gen(i) stat(mean) window(4)

. l company year invest i in 1/15

     +-----------------------------------+
     | company   year   invest         i |
     |-----------------------------------|
  1. |       1   1935    317.6         . |
  2. |       1   1936    391.8         . |
  3. |       1   1937    410.6         . |
  4. |       1   1938    257.7   344.425 |
  5. |       1   1939    330.8   347.725 |
     |-----------------------------------|
  6. |       1   1940    461.2   365.075 |
  7. |       1   1941      512   390.425 |
  8. |       1   1942      448       438 |
  9. |       1   1943    499.6     480.2 |
 10. |       1   1944    547.5   501.775 |
     |-----------------------------------|
 11. |       1   1945    561.2   514.075 |
 12. |       1   1946    688.1     574.1 |
 13. |       1   1947    568.9   591.425 |
 14. |       1   1948    529.2    586.85 |
 15. |       1   1949    555.1   585.325 |
     +-----------------------------------+

CLIVE NICHOLAS        |t: 0(044)7903 397793
Politics              |e: [email protected]
Newcastle University  |http://www.ncl.ac.uk/geps

Whereever you go and whatever you do, just remember this. No matter how
many like you, admire you, love you or adore you, the number of people
turning up to your funeral will be largely determined by local weather
conditions.

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



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index