Previous Page | Next Page

Macro Functions

%SYMEXIST Function

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

Required Argument



Required Argument


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


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.


The following example uses the %IF %THEN %ELSE macro statement to change the value of 1 and 0 to TRUE and FALSE respectively:

%global x;
%macro test;
    %local y;
        %if %symexist(x) %then %put %nrstr(%symexist(x)) = TRUE;
                         %else %put %nrstr(%symexist(x)) = FALSE;
        %if %symexist(y) %then %put %nrstr(%symexist(y)) = TRUE;
                         %else %put %nrstr(%symexist(y)) = FALSE;
        %if %symexist(z) %then %put %nrstr(%symexist(z)) = TRUE;
                         %else %put %nrstr(%symexist(z)) = FALSE;
%mend test;

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

%symexist(x) = TRUE
%symexist(y) = TRUE
%symexist(z) = FALSE

Previous Page | Next Page | Top of Page