Previous Page | Next Page

Macro Functions

%SYMLOCAL Function



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

Syntax
Required Argument
Details
Examples

Syntax

%SYMLOCAL(macro-variable-name)


Required Argument

macro-variable-name

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


Details

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.


Examples

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

Previous Page | Next Page | Top of Page