Download existmac.sas existmac.sasSubmit a comment

/******************************************************************************
 * existmac - Compiled Macro Search
 *
 * Author: Richard A. DeVenezia, 6/28/91
 *
 * Function: Determine if a macro has been compiled, hence available
 *   for invocation.
 *
 * Inputs:
 *   macro    - Name of macro to look for.
 *   returnMV - Name of macro variable to contain return code
 *              caller must ensure macro variable &returnMV is scoped before calling existmac
 *
 * Result:
 *     0, The macro has not been compiled.
 *     1, The macro has been compiled.
 *
 ******************************************************************************/

%macro existmac (macro, returnMV);

  %let &returnMV = 0;

  proc catalog
    catalog=work.sasmacr;
    contents out=_macros_;
  quit;

  data _null_;
    set _macros_ (keep=name);

    if upcase(name) = "%upcase(&macro)" then do;
      call symput ("&returnMV","1");
      stop;
    end;
  run;

  proc delete data=_macros_;
  run;

%mend existmac;