Saving and loading options with proc optsave/optload into/from the registry
The following example uses
proc optsave to store the current set of
option values to the
registry, then changes the value of the
pagesize option, then loads the stored options and verifies if the option had been reverted back to the original value.
Additionally, it uses
proc registry to view the subkey of the registry where the options were stored to.
options pagesize=99;
/* Verify current value of pagesize: */
%put %sysfunc(getoption(pagesize));
/* Store options in registry: */
proc optsave
key='TQ84\OPTIONS_SAVE';
run;
/* View the contents of the registry under the
key where the option values had been saved to: */
proc registry
list
startat='TQ84\OPTIONS_SAVE';
run;
/* Change an option temporarily: */
options pagesize=100;
/* Verify current value of pagesize: */
%put %sysfunc(getoption(pagesize));
/* Load stored options: */
proc optload
key='TQ84\OPTIONS_SAVE';
run;
/* Check pagesize again. It should be reverted to 99: */
%put %sysfunc(getoption(pagesize));
Saving and loading options to/from a data set
The following example is similar in spirit as the one above, yet instead of storing the option values into the registry, it stores the values into a
data set.
options pagesize=99;
/* Verify current value of pagesize: */
%put %sysfunc(getoption(pagesize));
/* Store options in registry: */
proc optsave
out=work.options_save;
run;
/* What variables are stored in the dataset? */
proc contents
data=work.options_save
varnum;
run;
/* The dataset contains two variables:
OPTNAME and OPTVALUE. This was of course
expected. */
proc print
data = sashelp.vcolumn;
var name;
where libname = 'WORK' and
memname = 'OPTIONS_SAVE';
run;
/* Showing the stored option values whose names
start with PAGE: */
proc print
data = work.options_save;
where optname eq: 'PAGE';
run;
/* Change an option temporarily: */
options pagesize=100;
/* Verify current value of pagesize: */
%put %sysfunc(getoption(pagesize));
/* Load stored options: */
proc optload
data = work.options_save;
run;
/* Check pagesize again. It should be reverted to 99: */
%put %sysfunc(getoption(pagesize));