Statalist The Stata Listserver


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

Re: st: gen lag variable


From   "Austin Nichols" <austinnichols@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: gen lag variable
Date   Wed, 2 Aug 2006 16:27:52 -0400

irodriguez --
Heed the excellent advice you were given in the thread with the
subject line "superposed rolled windows" (e.g
http://www.stata.com/statalist/archive/2006-06/msg00876.html)
viz. -tsset- your data and use the time-series operators (since these
will not create false lags when there are gaps in series, e.g. only
1990 and 1993-1995 are in the data but your bys firm (year): g
lagx=x[_n-1] puts the value of x in 1990 as the lagged x in 1993).

See [U] 13.8 and -help tsset- and -help tsvarlist- for starters.
--a

On 8/2/06, irodriguez <irodriguez@utdt.edu> wrote:
I have a panel data for 1200 firms by year (10 years for each firm)
I need to create a lagged variable of one called  roa but it must be lagged
for each firm
I tried with
by empresa: egen lagroa= roa[_n-1]
but the command give me this error: r(198)
What can I do?
Thanks


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