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]

RE: st: moving average with event data


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

Antonis,

That worked perfectly, THANKS!

Best,
April

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of A Loumiotis
Sent: Tuesday, December 27, 2011 10:15 AM
To: [email protected]
Subject: Re: st: moving average with event data

Hi Knill,
You could use -tsfill- to fill in the gaps in your time variable.
Best,
Antonis

On Tue, Dec 27, 2011 at 4:32 PM, Knill, April <[email protected]> wrote:
> 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/

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



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