Returns an indication as to whether a macro variable is local
in scope.
%SYMLOCAL(macro-variable-name)
|
- macro-variable-name
-
is the name of a macro variable or a text expression that
yields the name of a macro variable.
The %SYMLOCAL searches enclosing scopes for the indicated
macro variable and returns a value of 1 if
the macro variable is found in a local symbol table, otherwise it returns
a 0. See Scopes of Macro Variables
for more information about the global and local symbol tables and macro variable
scopes.
The following example uses the %IF %THEN %ELSE macro statement to change
the values of 1 and 0
to TRUE and FALSE
respectively:
%global x;
%macro test;
%local y;
%if %symlocal(x) %then %put %nrstr(%symlocal(x)) = TRUE;
%else %put %nrstr(%symlocal(x)) = FALSE;
%if %symlocal(y) %then %put %nrstr(%symlocal(y)) = TRUE;
%else %put %nrstr(%symlocal(y)) = FALSE;
%if %symlocal(z) %then %put %nrstr(%symlocal(z)) = TRUE;
%else %put %nrstr(%symlocal(z)) = FALSE;
%mend test;
%test;
In the example above, executing the %TEST macro writes the following
output to the SAS log:
%symlocal(x) = FALSE
%symlocal(y) = TRUE
%symlocal(z) = FALSE
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.