Previous Page | Next Page

DATA Step Functions for Macros

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 also:

SYMGET Function

CALL SYMPUT Routine

CALL SYMPUTN Routine


Syntax
Details
Comparisons
Example
Storing a Macro Variable Value as a Numeric Value In an SCL Program

Syntax

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

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.  [cautionend]


Comparisons


Example


Example 1: 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');

Previous Page | Next Page | Top of Page