i write general purpose macros in sas. within macro want apply settings,
- macro variables
- sas options
- ods options
but afterwards want "clean mess".
for macro variable
%macro mymac(); %let old_mac_var = &mac_var; %let mac_var = my_variable; %put doing stuf &mac_var.; %let mac_var = &old_mac_var; %mend; %let mac_var = value before; %mymac; %put mac_var &mac_var;
(of course solve using local macro variable in practice, that's not relevant.)
but how do other settings? i.e. how complete code?
%macro test_mprint(should_shouldnot); data _null_; put "note: 'data _null_;' &should_shouldnot. readable here above in log"; run; %mend; %macro mymac(); %let sas_mprint = ...; %let ods_exclude = ...; options nomprint; ods exclude none; title 'cars should printed because of ods option exclude none'; proc print data=sashelp.class; run; %test_mprint(should not); options &sas_mprint.; ods exclude &ods_exclude.; %mend; options mprint; ods exclude all; %mymac; title 'printing class should avoided ods option exclude all'; proc print data=sashelp.class; run; %test_mprint(should);
the sas options easy retrieve:
%let sas_mprint = %sysfunc(getoption(mprint)); /* gives, eg, nomprint */
ods options not sure..
Comments
Post a Comment