Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st:how to create yearly lag in monthly data?


From   "Michael S. Hanson" <mshanson@mac.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st:how to create yearly lag in monthly data?
Date   Tue, 2 May 2006 15:59:41 -0400

On May 2, 2006, at 2:24 PM, Badri wrote:

Dear Stata users and experts,
I'm dealing with a monthly data for a few years.
Let me denote month no., by m and year no., by y.  What I need to do
is to generate a variable B{m,y}=A{m,y-1}. A is a variable that is
already in the dataset.

This sounded quite simple to me till I tried a lot in vain.

Could anyone give a solution for this simple problem?
Assuming your data are -tsset- at a monthly frequency, you can use the lag operator: L12.a will give you the 12-month (i.e. one-year) lag of the variable 'a'. Additional information is available in [U] 11.4.3, or (in Stata 9.2) type -hsearch lag operator-. HTH.

-- Mike


*
* 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index