Hi, I have panel data set by countrycode and year, with multiple imputations.
When I try to sort data and command:
for some reason the imputed dataset loses variability, i.e. all the observations for non-imputed variable are the same. e.g. for US in years 2000-2010 I imputed var1. When I sort by countrycode and year, var2, var3 etc are just the same value for all US observations in 2000-2010.
Now to what I was actually doing this for: trying to create lags of my variables.
What I had in mind for code was:
As mentioned above, that problem with sorting arises. Is it possible to create lagged variables for imputed data and if so, what is the code?
When I try to sort data and command:
Code:
sort countrycode year
Now to what I was actually doing this for: trying to create lags of my variables.
What I had in mind for code was:
Code:
sort countrycode year by countrycode: gen lagvar1 = var1[_n-1] if year==year[_n-1]+1
Comment