defined | Determine if a macro variable is defined | defined |
The DEFINED macro returns a value of 0 (false) if the argument is the name of a non-existent macro variable. It returns a 1 if the macro variable exists in the global macro environment.
You can check if a macro variable has been defined by checking the dictionary.macro or sashelp.vmacro view. This version was provided in a sas-l posting by David Ward.
The DEFINED macro is usually used within other macros, e.g.,
%global test; %let test=3;
%include macros(defined); *-- or include in an autocall library; %macro testit; %if %defined(test) %then put TEST is defined as &test; %else put TEST is undefined; %mend; %testit;
TEST is defined as 3