Once a variable is declared to be in an array, it is in the array, I don't think you can remove it during the same data step.
Perhaps you could explain the bigger picture, what you are doing, why you are doing it, what removing from array really means, etc. ?
From the dataset keep only those variables that are not missing in all observations. data temp; input var1-var6; datalines; 1 2 3 4 5 6 . 1 2 3 4 6 . . 2 0 . 6 4 5 6 7 8 6 1 . 3 4 . 6 ; run;
data temp;
input var1-var6;
datalines;
1 2 3 4 5 6
. 1 2 3 4 6
. . 2 0 . 6
4 5 6 7 8 6
1 . 3 4 . 6
;
run;
data _null_;
set temp end=EOF;
array v var1-var6;
array N null1-null6;
do over v;
if missing(v) then n=1;
end;
if EOF then
do;
call execute("data new_temp; set temp(drop=");
do over v;
if n then call execute(vname(v));
end;
call execute("); run;");
end;
run;
Right, should be:
if missing(v) then n+1;
instead `n=1`.
Bart
So this really has nothing to do with arrays? Just remove a variable from the data set (not from the array) if it has a missing?
proc summary data=temp;
var var1-var6;
output out=stats nmiss=;
run;
proc transpose data=stats(drop=_type_ _freq_) out=stats1;
run;
proc sql noprint;
select distinct _name_ into :names separated by ' ' from stats1 where col1=0;
quit;
data want;
set temp(keep=&names);
run;
Can you provide more details this is somewhat vague
data temp;
input var1-var6;
datalines;
1 2 3 4 5 6
. 1 2 3 4 6
. . 2 0 . 6
4 5 6 7 8 6
1 . 3 4 . 6
;
run;
ods select none;
ods output nlevels=nlevels;
proc freq data=temp nlevels;
table _all_;
run;
ods select all;
proc sql noprint;
select TableVar into :keep separated by ' ' from nlevels where NMissLevels=0;
quit;
data want;
set temp;
keep &keep.;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.