Reputation: 703
I have this piece of code
%macro test(full);
%if &full. = 0 %then %do;
data temp;
set sashelp.air;
run;
%end;
%if &full. = 1 %then %do;
data temp;
set sashelp.air;
where air > 140;
run;
%end;
%mend;
%test(1);
or in open code
%let full = 1;
%if &full. = 0 %then %do;
data temp;
set sashelp.air;
run;
%end;
%if &full. = 1 %then %do;
data temp;
set sashelp.air;
where air > 140;
run;
%end;
is there a way to get something like (this code doesn't work):
%macro test(full);
data temp;
set sashelp.air;
%if &full. = 0 %then %do; %sysfunc(call execute('where air>140;')); %end;
run;
%mend;
%test(1);
or in open code, of course. I would like to make the condition working only inside the datastep, avoiding entire datastep repetition.
Upvotes: 0
Views: 28
Reputation: 51566
Just remove the unneeded complications. Also I assume you did not mean to reverse the logic of when the WHERE clause is generated.
data temp;
set sashelp.air;
%if &full.=1 %then %do;
where air>140;
%end;
run;
Upvotes: 1