| DATA Step Functions for Macros |
| Type: | SCL function | |||
| See also: |
|
| Syntax | |
| Details | |
| Comparisons | |
| Example | |
| Storing a Macro Variable Value as a Numeric Value In an SCL Program | |
Syntax |
| SCL-variable=SYMGETN('macro-variable'); |
is the name of a numeric SCL variable to contain the value stored in 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=¯o-variable;
Note: It is inefficient to use SYMGETN to retrieve values that
are not assigned with SYMPUTN and values that are not numeric. ![[cautionend]](../../../../common/63294/HTML/default/images/cautend.gif)
| 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 |
This statement stores the value of the macro variable UNIT in the SCL variable UNITNUM when the SCL program executes:
unitnum=symgetn('unit');
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.