SAS Tip: Using GETOPTION to Save and Restore Options (Daily tip for 2024-Jul-27)


You can use the GETOPTION function to query for the current value of an option. And if you wrap the call the GETOPTION function with the %SYSFUNC macro function, you can save the value in a macro variable so it can be easily restored. For example, the following will enable you to use NOCENTER NONUMBER NODATE for some output and then reset the values back to their original values:

%let saveOptions = %sysfunc(getoption(CENTER)) %sysfunc(getoption(NUMBER)) %sysfunc(getoption(DATE));
options nocenter nonumber nodate;

/* your code that depends on these options */

options &saveOptions; /* reset options to original values */

Thanks to Don Henderson for sharing this tip on sasCommunity.org.

READ this complete tip   Visit a random SAS tip

Start a topic
About these Tips
A "SAS tip" is a basic unit of information exchange between SAS users. The tips on this board come from sasCommunity.org, from SAS user conferences, from SAS blogs, and from freelance contributions from SAS users like you. We hope that you're able to always learn something new here!


» How you can contribute


Tip-o-meter: 63 tips