SYMGETN Function

In SAS Component Control Language (SCL) programs, returns the value of a global macro variable as a numeric value.
Type: SCL function
See: SYMGET Function, CALL SYMPUT Routine, and CALL SYMPUTN Routine

Syntax

SCL-variable=SYMGETN('macro-variable');

Required Arguments

SCL variable
is the name of a numeric SCL variable to contain the value stored in macro-variable.
macro-variable
is the name of a global macro variable with no ampersand – note the single quotation marks. Or, the name of an SCL variable that contains the name of a global macro variable.

Details

SYMGETN returns the value of a global macro variable as a numeric value and stores it in the specified numeric SCL variable. You can also use SYMGETN to retrieve the value of a macro variable whose name is stored in an SCL variable. For example, to retrieve the value of SCL variable UNITVAR, whose value is 'UNIT', submit the following code:
unitnum=symgetn(unitvar)
SYMGETN returns values when SCL programs execute. If SYMGETN cannot locate macro-variable, it returns a missing value.
To return the value stored in a macro variable when an SCL program compiles, use a macro variable reference in an assignment statement:
SCL variable=&macro-variable;
Note: It is inefficient to use SYMGETN to retrieve values that are not assigned with SYMPUTN and values that are not numeric.

Comparisons

  • SYMGETN is available only in SCL programs, but SYMGET is available in DATA step programs and SCL programs.
  • SYMGETN retrieves values, but SYMPUTN assigns values.

Example: Storing a Macro Variable Value as a Numeric Value in an SCL Program

This statement stores the value of the macro variable UNIT in the SCL variable UNITNUM when the SCL program executes:
unitnum=symgetn('unit');