i have a data set containing columns x y z. data set contains 10 records. i want to check if x has a value for each observation. however if all 10 records have a value of missing or 0 in x, i want to delete the column x. how can i do that?
For this we need to run PROC MEANS with (N NMISS MIN MAX) on the data first to identify those variables having missing values or zero's.
After this we can drop those variables whose N=NMISS or (MIN=0 and MAX=0) by using DROP or KEEP.
if you are generating this table in a data step, you could create a retained variable to count the number of time that x is missing and then on the last observation, compare that variable with _n_ and if they are equal conditionally execute a data step to drop that variable...like:
set abc(keep=x y z) end=lastone;
retain x_missing 0;
x_missing = x_missing + missing(x);
if lastone then do;
if x_missing = _n_ then call execute('data def;set xyz(keep=y z);run;');