Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: moving average with event data


From   "Knill, April" <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: moving average with event data
Date   Tue, 27 Dec 2011 14:32:50 +0000

I am trying to create a five-year moving average using data that has payments. The data contain only years where there are payments, i.e., there are no observations when payments are not made. So, for example, for the data below, I would like Stata to calculate a trailing 5-year average for firm 2177 in the year 2000 as (1000 + 0 + 500 + 1000 + 0)/5. In other words, for the non-observations, Stata should count this as a zero. This is different than the posts I saw which actually had an observation for ALL years and simply a "." If the data were a manageable size I could just go in input the observations but this is a dataset of several thousand firms. Can I still create this moving average?

FirmNo                 Year                       DollarPmnt
2177                       1991                       41700
2177                       1992                       44850
2177                       1994                       32900
2177                       1995                       33200
2177                       1997                       41350
2177                       2000                       60958
3331                       1991                       1000
3331                       1996                       4500
10002                    1992                       800
10002                    1997                       1000
10002                    1998                       500
10002                    2000                       1000
10002                    2001                       2000
10002                    2002                       2500
10002                    2003                       2000
10002                    2004                       1000


Best Regards,
 
April Knill, Ph.D.



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index