I am trying to conditionally drop variables from a data set. %macro drop_correlated(data_set);
%macro dummy; %mend dummy;
proc corr data=&data_set. pearson NOPROB nomiss Rank NoProb outp=correlations;
run;
data reduced;
set correlations;
where _TYPE_ = "CORR";
run;
data reduced;
set reduced;
drop _TYPE_;
run;
data _null_;
set reduced;
call symput(cat('VAR_',_N_),compress(trim(left(_NAME_))));
call symput('NUM_VAR',_N_);
run;
%local i;
%do i=1 %to &NUM_VAR.;
data temp_&i.;
set reduced;
where _name_ = "&&VAR_&i.";
drop _name_;
run;
%local j;
%do j=1 %to &NUM_VAR.;
data temp_&i.;
set temp_&i.;
if (-0.5 <= &&VAR_&j. <= 0.5) then %drop_var(temp_&i, &&VAR_&j.);
run;
%end;
%end;
%put _ALL_;
%mend drop_correlated;
%macro drop_var(data_in, var);
%macro dummy; %mend dummy;
data &data_in.;
set &data_in.;
drop &var.;
run;
%mend drop_var;
%drop_correlated(data); I get the error: ERROR 180-322: Statement is not valid or it is used out of proper order. I think this is coming from the drop_var macro.
... View more