I have a data set as follows: Date Var1 Var2 Var3 Var 4 Var 5 .... Var3000 10/25 5 2 1 8 10/24 10/23 10/22 10/21 2 4 2 6 5 10/20 10/19 10/18 10/17 4 5 1 5 7 I would like to replace the missing values with the previous values across all 3000 variables. But I would like to replace then with the next value if there is no previous value (such as Var4 and Var3000). I have successfully replaced the missing values with the previous values with the following code: data want;
set have;
array vars{*} _numeric_; array latest{3000} _temporary_; do i = 1 to dim(vars); if vars{i} > . then latest{i} = vars{i}; else vars{i} = latest{i}; end; run; How can I also replace missing values with the following values that is not missing? Should I introduce another temporary array?
... View more