I would like to impute missing values repeatedly, first with the past value, then with the future value:
However, this code is long because there are 4 survey waves. How is it possible to keep this in 2 lines?
HTML Code:
foreach v of varlist drinkl socwk higov { // need code to repeat this 4 times in each direction bysort ID: replace `v' =`v'[_n-1] if `v'>=. bysort ID: replace `v' =`v'[_n-1] if `v'>=. bysort ID: replace `v' =`v'[_n-1] if `v'>=. bysort ID: replace `v' =`v'[_n-1] if `v'>=. bysort ID: replace `v' =`v'[_n+1] if `v'>=. bysort ID: replace `v' =`v'[_n+1] if `v'>=. bysort ID: replace `v' =`v'[_n+1] if `v'>=. bysort ID: replace `v' =`v'[_n+1] if `v'>=. }
Comment