Statalist The Stata Listserver

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

Re: st: gen lag variable

From   "Austin Nichols" <>
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
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.

On 8/2/06, irodriguez <> 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?

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index