stata - How to Lag in Different Time Periods? -


i using large panel data covering years 1970 2002. 1 of variables has observation years 1985, 1995, 1999 , 2002. variable looks follows:

     +-------------------------+      | country   year   groups |      |-------------------------|   1. | germany   1985        5 |   2. | germany   1995       10 |   3. | germany   1997        . |   4. | germany   1998        . |   5. | germany   1999       20 |      +-------------------------+ 

my intention lag groups variable next observation. have created dummy showing 1 these time periods, don't know how take next step. can lag group variable?

it not entirely clear me whether want groups represent value of next or of previous year. anyhow, syntax simple if have each country/year once in dataset:

bysort country year: replace groups=groups[_n-1] //for previous observation  bysort country year: replace groups=groups[_n+1] //for next observation  

i not sure why doing this, maybe want rid of missing values. in case take @ this post or on carryforward ssc.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -