Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: creating lags


From   "Jennifer Ng" <[email protected]>
To   <[email protected]>
Subject   st: RE: creating lags
Date   Sat, 29 Mar 2003 16:55:53 -0800

Hi Maria,
I don't really understand your data but I think you can try lag5_var =
var[_n-5] or lag5_var = L5.var.  Hope it can help you
Cheers,
Jennifer



-----Original Message-----
From: [email protected]
[mailto:[email protected]]On Behalf Of Maria Popova
Sent: Saturday, March 29, 2003 4:04 PM
To: [email protected]
Subject: st: creating lags


Hi all,

I have a time series/cross section data set and I'm trying to create 5-year
lags for several variables.  I have data on 158 countries between 1966 and
1997, but of course since not all countries existed for the entire period,
different countries have data for different sets of years.  I've sorted the
data by time and within the time groups by country and then I tried
creating the lags with:

gen lag5_var=var[_n-790] (because 158*5=790)

However, the resulting lag is incorrect... What am I doing wrong?  Do I
have to generate missing values for the country-years that are not in the
data set?  I thought Stata is supposed to do that for me...

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/

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