Hello members,
How can I clear the results and outputs generated by the procedures within a macro? For example, for the following code. How can I only keep the data2 in within the macro and clear the intermediate results generated by % macro bydomain (conditon1=a, condition2=b); before run % macro bydomain (conditon1=c, condition2=d);?
Data data2;
set data1;
run;
% macro bydomain (conditon1, condition2);
data data2;
...
run;
%mend;
% macro bydomain (conditon1=a, condition2=b);
% macro bydomain (conditon1=c, condition2=d);
...
Thanks so much!!!
Incase you you are trying to just delete specific intermediate datasets only, try this.
%macro bydomain (conditon1, condition2);
proc datasets nolist lib=work mtype=data;
delete data2;
quit;
data data2;
...
run;
%mend;
https://blogs.sas.com/content/iml/2015/05/28/five-reasons-ods-exclude.html
ODS SELECT and ODS EXCLUDE are what are needed. Or NOPRINT within the various procs.
First thing would be to provide a more detailed description and possibly use different data set names in the example.
You only actually show one data set inside the macro, repeating the name of one outside, and it is not clear what you want to keep.
Typically I would use proc datasets to delete any datasets that I don't want. Either at the beginning of a macro to prevent reuse of an existing set or at the end of the macro to clean up before it ends.
The syntax is
Proc datasets library=somelib;
delete datasetname;
quit;
you may want the NOPRINT option to reduce any output in the log
Incase you you are trying to just delete specific intermediate datasets only, try this.
%macro bydomain (conditon1, condition2);
proc datasets nolist lib=work mtype=data;
delete data2;
quit;
data data2;
...
run;
%mend;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.