data have;
input a b c;
datalines;
1 . 2
. 3 4
6 7 .
8 9 10
11 12 13
;
proc transpose data=have out=have_trans;
run;
%macro mymacro(dsn=, out=);
data &out;
set &dsn;
array col{5};
do i = 1 to dim(col);
if col(i) = . then do;
do j = i to dim(col)-1;
col(j) = col(j+1);
end;
end;
end;
drop i j;
run;
%mend mymacro;
%mymac ...
data have;
input a b c;
datalines;
1 . 2
. 3 4
6 7 .
8 9 10
11 12 13
;
proc transpose data=have out=have_trans;
run;
%macro mymacro(dsn=, out=);
data &out;
set &dsn;
array col{5};
do i = 1 to dim(col);
if col(i) = . then do;
do j = i to dim(col)-1;
col(j) = col(j+1);
end;
end;
end;
drop i j;
run;
%mend mymacro;
%mymacro(dsn=have_trans, out=have_out);
proc iml;
use out.case;
read all var _char_ into caseiml;
do i=1 to nrow(caseiml)-1;
do j=1 to ncol(caseiml);
if missing(caseiml[i,j]) then do;
do k=1 to nrow(caseiml);
if not missing(caseiml[i+k,j]) then do;
caseiml[i,j]=caseiml[i+k,j];caseiml[i+k,j]="";
end;
end;
end;
end;
end;
create out.examm from caseiml;
append from caseiml;
submit the macro again
%mymacro(dsn=have_out, out=have_out_1);
then run the proc transform use the new result dataset have_out_1.
If there are five 连续 missing, then submit the macro five times with the same input and output dataset name. To see the result of each time you submit the macro, you can change the input and output dataset every time as above.