How is this code.
data sample;
length a b c $10 d e f 8;
infile datalines dsd missover;
input a b c d e f;
datalines;
aa,bb, ,1, ,3
aa, ,cc,1,2,3
dd,x , , ,6,
, ,bc,9, ,7
, ,cc, , ,
;
run;
/* remember number of variables */
data _null_;
set sashelp.vtable;
where memname='SAMPLE';
call symputx('cvars',num_character);
call symputx('nvars',num_numeric);
run;
data want(drop=i);
set sample;
array _n{&nvars.} _numeric_;
array _c{&cvars.} _character_;
array _rn{&nvars.} 8 _temporary_;/* variables for keeping data of previous observation */
array _rc{&cvars.} $ _temporary_;/* variables for keeping data of previous observation */
retain _rc: _rn:;
do i=1 to dim(_n);
if missing(_n{i}) then _n{i}=_rn{i};
_rn{i}=_n{i};
end;
do i=1 to dim(_c);
if missing(_c{i}) then _c{i}=_rc{i};
_rc{i}=_c{i};
end;
run;
... View more