Hi, Here is a SAS macros solution that does not need a proc transpose. *** Find all the column variables where all records are zero; data data_file; input col1 col2 col3; cards; 0 0 0 1 0 2 1 0 3 ; %macro find_zeros(input_data=); *** Find all the column variables in the input dataset; proc contents data = &input_data; noprint out = _varlst_ (keep = name); *** Convert all your column variables to macro variables; proc sql noprint; select count (*) into :incrn from _varlst_; select name into :varn1-:varn%left(&incrn) from _varlst_; quit; *** Create a cumulative sum for each column variable. The last observation in this dataset will contain the total sum. A zero will indicate that all records for that column variable are zero.; data cumulative_sum; input &input_data; %do k=1 %to &incrn; %let check_zero_&&varn&k=0; check_zero_&&varn&k + &&varn&k; retain check_zero_&&varn&k; %end; *** Now list all your variables and those with a zero entry are the ones you want; data zero_variables_present(drop=%do y=1 %to &incrn; &&varn&y %end; ); set cumulative_sum end=last; %do m=1 %to &incrn; if last and check_zero_&&varn&m = 0 then output; %end; *** Reduce the list to only those variables that are zero; data keep_only_zero_variables(%do k=1 %to &incrn; keep= %if check_zero_&&varn&k = 0 %then %do; check_zero_&&varn&k %end; %end; ); set zero_variables_present; run;quit; %mend; %find_zeros(input_data=data_file); The dataset, "zero_variables_present" should give the result Obs check_zero_col1 check_zero_col2 check_zero_col3 1 2 0 5 With the dataset, "keep_only_zero_variables" giving Obs check_zero_col2 1 0 Which is the desired result.
... View more