%SYMGLOBL Function

Returns an indication as to whether a macro variable is global in scope.
Type: Macro function

Syntax

%SYMGLOBL(macro-variable-name)

Required Argument

macro-variable-name
is a name of a macro variable or a text expression that yields the name of a macro variable.

Details

The %SYMGLOBL function searches enclosing scopes for the indicated macro variable and returns a value of 1 if the macro variable is found in the global 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.

Example: Using %SYMGLOBL Macro Function

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 %symglobl(x) %then %put %nrstr(%symglobl(x)) = TRUE;
                         %else %put %nrstr(%symglobl(x)) = FALSE;
        %if %symglobl(y) %then %put %nrstr(%symglobl(y)) = TRUE;
                         %else %put %nrstr(%symglobl(y)) = FALSE;
        %if %symglobl(z) %then %put %nrstr(%symglobl(z)) = TRUE;
                         %else %put %nrstr(%symglobl(z)) = FALSE;
%mend test;
%test;
In the example above, executing the %TEST macro writes the following output to the SAS log:
%symglobl(x) = TRUE
%symglobl(y) = FALSE
%symglobl(z) = FALSE