%SYMEXIST(macro-var-name), , -var, %IF , %IF . , , . , , , , .
%macro wrapper;
%if %symexist(foo_defined) %then %return;
%macro foo;
%global foo_defined;
%let foo_defined = 1;
%put i am foo;
%mend foo;
%mend wrapper;
%*-- tests --*;
options mcompilenote=all;
%symdel foo_defined;
%*-- first time it will define %foo --*;
%wrapper
%foo
/* on log
NOTE: The macro FOO completed compilation without errors.
6 instructions 108 bytes.
i am foo
*/
%*-- second time it will not --*;
%wrapper
%foo
/* on log
(no notes on macro compilation)
i am foo
*/
SAS , (/ ) . , , , . (gory) :
http://support.sas.com/resources/papers/proceedings09/076-2009.pdf