Macro Functions |
Type: | Macro function |
Syntax | |
Required Argument | |
Details | |
Examples |
Syntax |
%SYMEXIST(macro-variable-name) |
is the name of a macro variable or a text expression that yields the name of a macro variable.
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 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; %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
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.