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

st: Re: creating lags

From   "Scott Merryman" <>
To   <>
Subject   st: Re: creating lags
Date   Sat, 29 Mar 2003 22:02:50 -0600

----- Original Message -----
From: "Maria Popova" <>
To: <>
Sent: Saturday, March 29, 2003 6:04 PM
Subject: st: creating lags

> Hi all,
> I have a time series/cross section data set and I'm trying to create
> 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
> 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!
Stata does support lag, forward, difference, and seasonal operators.
 See -whelp varlist-

You could:
gen lag5_var = L5.var

Stata will generate the 5 period lag for each panel.


*   For searches and help try:

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