Look into using PROC OPTSAVE in the initial macro and then let the the other macro(s) use OPTSAVE/PROC COMPARE to determine if there have been changes and reset them using OPTLOAD.
I use this technique in macro where I want to preserve and reset the users options after I change them in my macro.
/*------------------------------------------------------------------------*
| Reset system options changed by the macro.
*------------------------------------------------------------------------*/
proc optsave out=&m._optsave2;
run;
proc compare noprint base=&m._optsave1 compare=&m._optsave2 outbase outnoequal out=&m._optchange;
run;
data _null_;
set &m._optchange;
if _N_ eq 1 then put 'NOTE: The following options are being reset to previous values.';
put 'NOTE- ' (OPTNAME OPTVALUE)(=);
run;
proc optload data=&m._optchange(keep=optname optvalue);
run;
Probably not. Another approach would be to capture the original option settings, and then restore options to those original values as your macro begins to execute.
If a Macro or program requires specific options I would recommend making sure that they are available when needed. You can use the OPTSAVE procedure to capture a users options and OPTLOAD to set the options you need and then restore the users options after the options are no longer needed.
Since the OPTLOAD uses a dataset then your implementation of the preferred options would be calling the procedure with a dataset containing the options needed.
So your macros could contain code like:
Proc optsave out=lib.useropts;run;
Proc optload data=permlib.macroopts;run;
<other macro code>
Proc optload data=lib.useropts;run;
Look into using PROC OPTSAVE in the initial macro and then let the the other macro(s) use OPTSAVE/PROC COMPARE to determine if there have been changes and reset them using OPTLOAD.
I use this technique in macro where I want to preserve and reset the users options after I change them in my macro.
/*------------------------------------------------------------------------*
| Reset system options changed by the macro.
*------------------------------------------------------------------------*/
proc optsave out=&m._optsave2;
run;
proc compare noprint base=&m._optsave1 compare=&m._optsave2 outbase outnoequal out=&m._optchange;
run;
data _null_;
set &m._optchange;
if _N_ eq 1 then put 'NOTE: The following options are being reset to previous values.';
put 'NOTE- ' (OPTNAME OPTVALUE)(=);
run;
proc optload data=&m._optchange(keep=optname optvalue);
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.