Dear all,
I have a question regarding creating a leading variable.
In my data, I have some missing years from different companies and I only want to lead successive year. So I know this code for creating a lagged variable:
by state: gen lag1 = x[_n-1] if year==year[_n-1]+1
For my dataset, the code would be:
by gvkey: gen tobinsqlead = tobinsq_w[_n-1] if year==year[_n-1]+1
Only thing is, this is the code for creating a lagged variable if you have missing years, but I want to create a leading variable.
I am not able to rewrite the code into a leading one. When I "play" with the - and + I constantly get the message "weights not allowed"
Can someone help me with this?
Regards,
I have a question regarding creating a leading variable.
In my data, I have some missing years from different companies and I only want to lead successive year. So I know this code for creating a lagged variable:
by state: gen lag1 = x[_n-1] if year==year[_n-1]+1
For my dataset, the code would be:
by gvkey: gen tobinsqlead = tobinsq_w[_n-1] if year==year[_n-1]+1
Only thing is, this is the code for creating a lagged variable if you have missing years, but I want to create a leading variable.
I am not able to rewrite the code into a leading one. When I "play" with the - and + I constantly get the message "weights not allowed"
Can someone help me with this?
Regards,

Comment