Hello,

I have yearly panel data on 4 variables for all U.S. states, and the data are in wide format. There is some missing data, as some states failed to report information for a given variable-year, while other states missed large chunks of years. I am trying to linearly interpolate missing data, but only if a state has data for the year prior to and after the missing year (illustration below). Can someone help we with the code for specifying this IF condition?


State V1_1980 V1_1981 V1_1982 V1_1983 V1_1984
AK 1 Miss 7 14 19 <--- linearly interpolate
AL 10 Miss Miss 40 56 <--- do not linearly interpolate


Thank you for your help,
Tom