I have the following code, I am trying to generate a standalone code from the macro (written to an external sas file). However, by default the complete code is generated and written to the external file. I would like to know if there is a way by which one can control, which parts of the macro are written to the external file. Appreciate all the help I can get on this.
%macro tempmacro(outds=);
/* I dont want this following code to be printed */
proc sql noprint;
SELECT cats(name,"=",substr(name,2))
INTO :renames SEPARATED BY " "
FROM dictionary.columns
WHERE LIBNAME="SASHELP" AND MEMNAME=upcase('BASEBALL');
quit;
/* I only Want this following data step printed to the external file */
data &outds;
set sashelp.baseball;
rename &renames;
run;
%mend;
options mfile mprint;
filename mprint "D:\test_code.sas";
data _null_;
file mprint;
%tempmacro(outds=data1);
options nomfile nomprint;
run;
Set option nomprint
before your proc sql
and then option mprint
afterwards to restore it. For bonus UX points, check what the value of the option was before using %sysfunc(getoption(mprint))
at the start of your macro, and restore it to the same value afterwards.