Functions and CALL Routines |
Category: | Special |
Syntax | |
Arguments | |
Examples | |
Example 1: Using GETOPTION to Save and Restore the YEARCUTOFF Option | |
Example 2: Using GETOPTION to Obtain Different Reporting Options |
Syntax |
GETOPTION(option-name<,reporting-options<,...>>) |
is a character constant, variable, or expression that specifies the name of the system option.
is a character constant, variable, or expression that specifies the reporting options. You can separate the options with blanks, or you can specify each reporting option as a separate argument to the GETOPTION function. The following is a list of reporting options:
Examples |
This example saves the initial value of the YEARCUTOFF option and then resets the value to 1920. The DATA step that follows verifies the option setting and performs date processing. When the DATA step ends, the YEARCUTOFF option is set to its original value.
%let cutoff=%sysfunc(getoption (yearcutoff,keyword)); options yearcutoff=1920; data ages; if getoption('yearcutoff') = '1920' then do; ...more statements... end; else put 'Set Option YEARCUTOFF to 1920'; run; options &cutoff;
This example defines a macro to illustrate the use of the GETOPTION function to obtain the value of system and graphics options by using different reporting options.
%macro showopts; %put MAPS= %sysfunc( getoption(MAPS)); %put MAPSEXPANDED= %sysfunc( getoption(MAPS, EXPAND)); %put PAGESIZE= %sysfunc( getoption(PAGESIZE)); %put PAGESIZESETBY= %sysfunc( getoption(PAGESIZE, HOWSET)); %put PAGESIZESCOPE= %sysfunc( getoption(PAGESIZE, HOWSCOPE)); %put PS= %sysfunc( getoption(PS)); %put LS= %sysfunc( getoption(LS)); %put PS(keyword form)= %sysfunc( getoption(PS,keyword)); %put LS(keyword form)= %sysfunc( getoption(LS,keyword)); %put FORMCHAR= %sysfunc( getoption(FORMCHAR)); %put HSIZE= %sysfunc( getoption(HSIZE)); %put VSIZE= %sysfunc( getoption(VSIZE)); %put HSIZE(in/keyword form)= %sysfunc( getoption(HSIZE,in,keyword)); %put HSIZE(cm/keyword form)= %sysfunc( getoption(HSIZE,cm,keyword)); %put VSIZE(in/keyword form)= %sysfunc( getoption(VSIZE,in,keyword)); %put HSIZE(cm/keyword form)= %sysfunc( getoption(VSIZE,cm,keyword)); %mend; goptions VSIZE=8.5 in HSIZE=11 in; options PAGESIZE=67; %showopts
The following is SAS output from the example.
MAPS= !SASROOT\MAPS MAPSEXPANDED= ( 'C:\PROGRAM FILES\SAS\SAS 9.1\MAPS' ) PAGESIZE= 67 PAGESIZESETBY= OPTIONS STATEMENT PAGESIZESCOPE= DMS PROCESS PS= 23 LS= 76 PS(keyword form)= PS=23 LS(keyword form)= LS=76 FORMCHAR= |----|+|---+=|-/\<>* HSIZE= 11.0000 in. VSIZE= 8.5000 in. HSIZE(in/keyword form)= HSIZE=11.0000 in. HSIZE(cm/keyword form)= HSIZE=27.9400 cm. VSIZE(in/keyword form)= VSIZE=8.5000 in. HSIZE(cm/keyword form)= VSIZE=21.5900 cm.
Note: The default settings for the PAGESIZE= and the LINESIZE= options depend on the mode you use to run SAS.
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.