Previous Page | Next Page

DATA Step Functions for Macros

SYMLOCAL Function



Returns an indication as to whether a macro variable is local in scope to the DATA step during DATA step execution.
Type: DATA step function

Syntax
Required Argument
Details
Examples

Syntax

SYMLOCAL (argument)


Required Argument

argument

can be one of the following items:

  • the name of a macro variable within quotation marks but without an ampersand

  • the name of a DATA step character variable, specified with no quotation marks, that contains a macro variable name

  • a character expression that constructs a macro variable name


Details

The SYMLOCAL function 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 of the %TEST macro contains the SYMLOCAL function:

  %global x;
       %macro test;
       %local y;
       data null;
          if symlocal("x") then put "x is LOCAL";
                                 else put "x is not LOCAL";
          if symlocal("y") then put "y is LOCAL";
                                 else put "y is not LOCAL";
          if symlocal("z") then put "z is LOCAL";
                                 else put "z is not LOCAL";
       run;
       %mend test;
       %test;

In the previous example, executing the %TEST macro, which contains the SYMLOCAL function, writes the following output to the SAS log:

 x is not LOCAL
 y is LOCAL
 z is not LOCAL

Previous Page | Next Page | Top of Page