Previous Page | Next Page

DATA Step Functions for Macros

SYMEXIST Function



Returns an indication of the existence of a macro variable.
Type: DATA step function

Syntax
Required Argument
Details
Examples

Syntax

SYMEXIST (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, which contains a macro variable name

  • a character expression that constructs a macro variable name


Details

The SYMEXIST function searches any enclosing local symbol tables and then the global symbol table for the indicated macro variable and returns a value of 1 if the macro variable is found or a value of 0 if the macro variable is not found.


Examples

The following example of the %TEST macro contains the SYMEXIST function:

%global x;
       %macro test;
       %local y;
       data null;
          if symexist("x") then put "x EXISTS";
                                 else put "x does not EXIST";
          if symexist("y") then put "y EXISTS";
                                 else put "y does not EXIST";
          if symexist("z") then put "z EXISTS";
                                 else put "z does not EXIST";
       run;
       %mend test;
       %test;

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

 
x EXISTS
y EXISTS
z does not EXIST

Previous Page | Next Page | Top of Page