GETOPTION Function


GETOPTION Function

Returns the value of a SAS system or graphics option

Category: Special

Syntax

GETOPTION ( option- name <, reporting-options <, >>)

Arguments

option-name

  • is the name of the system option.

  • Tip: Do not put an equals sign after the name. For example, write PAGESIZE= as PAGESIZE.

    Note: SAS options that are passwords, such as EMAILPW and METAPASS, return the value xxxxxxxx , and not the actual password.

reporting-options

  • 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 reporting options are

IN

reports graphic units of measure in inches.

CM

reports graphic units of measure in centimeters.

KEYWORD

returns option values in a KEYWORD= format that would be suitable for direct use in the SAS OPTIONS or GOPTIONS global statements.

Examples

Example 1: Using GETOPTION to Change the YEARCUTOFF Option

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; 

Example 2: Using GETOPTION to Obtain Different Reporting Options

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 PAGESIZE= %sysfunc(       getoption(PAGESIZE));    %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;  %showopts; 

The following is SAS output from the example.

 PAGESIZE= 23  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 pagesize and linesize depend on the mode you use to run SAS.




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net