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

cookies - Yii2 Advanced - Share session between frontend and mainsite (duplicate of frontend for www) -

angular - password and confirm password field validation angular2 reactive forms -

php - Permission denied. Laravel linux server -