-gen variable = l0.variable- is not what you ran. If variable already exists, you can't -gen- it. If it doesn't exist, Stata will complain about your using it on the right hand side. It's really important to show exactly what you did. I'm guessing you did something like this:
and got 614 missing cases. Remember that since 2008 is your first year, there will be no lagged value for any observation with year == 2008. So you will have missing values whenever year == 2008. Since you have a total of 1842 observations, according to your data ex, 614 is exactly one third of that, and so it is exactly what I would expect. This version will give you the correct lagged values. Go with it.
If you did
then lrainfall will be not just "hardly different" from the real values, they will be exactly equal to the original values. l0 means a 0-order lag, i.e. no lag at all: the current value. So this clearly is of no real use here.
Code:
gen lrainfall = l1.rainfall
If you did
Code:
gen lrainfall = l0.rainfall
Comment