Dear Statalists,
I have a dataset in the following shape for several counties and years:
For all counties, the values for the years 1977 to 1979 are missing for "Variable" and I want to replace those missings with the value from the year 1980 of the respective county. I could find comments on how to fill in values from the top to the bottom but not vice versa. Does anyone have a suggestion for me? I suppose I will need a loop as I want to replace the values for several counties.
Thank you in advance!
I have a dataset in the following shape for several counties and years:
County | Year | Variable |
1 | 1977 | - |
1 | 1978 | - |
1 | 1979 | - |
1 | 1980 | 3000 |
1 | 1981 | 3000 |
... | ... | ... |
3 | 1977 | - |
3 | 1978 | - |
3 | 1979 | - |
3 | 1980 | 4000 |
3 | 1981 | 4000 |
... | ... | ... |
For all counties, the values for the years 1977 to 1979 are missing for "Variable" and I want to replace those missings with the value from the year 1980 of the respective county. I could find comments on how to fill in values from the top to the bottom but not vice versa. Does anyone have a suggestion for me? I suppose I will need a loop as I want to replace the values for several counties.
Thank you in advance!
Comment