Just make two passes over the array of values. Once from left to right and then again from right to left.
data have;
input id $ State1990-State1994;
cards;
001 5 . 1 1 6
002 . . 1 3 2
003 . . . 4 5
;
data want;
set have;
array x state: ;
do i=2 to dim(x);
x(i)=coalesce(x(i),x(i-1));
end;
do i=dim(x)-1 to 1 by -1;
x(i)=coalesce(x(i),x(i+1));
end;
drop i;
run;
... View more