Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | TA Stat <tastat@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Lag variables - generate missing values |
Date | Fri, 13 Jul 2012 10:20:49 +0700 |
http://www.stata.com/statalist/archive/2006-02/msg00573.html HTH Pete On Wed, Jul 11, 2012 at 6:41 PM, David Ashcraft <ashcraftd@rocketmail.com> wrote: > I am trying to generate a new variable by using the lag operator L. on a panel data set. When I use the lag operator, the generated variable return as ALL MISSING values. I am lost here. I have tried with old operator i.e. (_n-1) and the outcome is same. In my data set, id is the identifier and date1 is the date. Data is monthly from Jan2000 to may2010. > > I am using the following set of commands to generate the lag variable > > > . sort id date1 > > . tsset id date1, monthly > panel variable: id (unbalanced) > time variable: date1, 3180m1 to 3555m5, but with gaps > delta: 1 month > > . su rtn > > Variable Obs Mean Std. Dev. Min Max > > rtn 2814 1624.403 1884.28 71.81 14132.85 > > . describe rtn date1 id > > storage display value > variable name type format label variable label > rtn float %9.0g > date1 float %tm > id float %9.0g > > . gen return= ln(rtn/L.rtn) > (2814 missing values generated) > > Any help will be highly appreciated. > > David > > * > * 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/