SAS Drop variables when all values are missing

/*http://ftp.sas.com/techsup/download/sample/datastep/dropvar.html*/
%let abc=&syslast;
data _null_;
set &abc end=end;
array test (*) _numeric_;
* array allmiss (8) $ (8*'true');
array allmiss (3000) $ (3000*'true');

length list $ 5000;

do i=1 to dim(test);
if test(i) ne . then allmiss(i)='false';
end;
if end=1 then
do i= 1 to dim(test);
if allmiss(i) ='true' then list=trim(list)||' '||trim(vname(test(i)));
end;
call symput('mlist',list);
run;

data &abc ;
set &abc ;
drop &mlist;
run;

Leave a Reply