Chapter Contents

Previous

Next
SAS Macro Language: Reference

Writing the Contents of Symbol Tables to the SAS Log

While developing your macros, you may find it useful to write all or part of the contents of the global and local symbol tables to the SAS log. To do so, use the %PUT statement with one of the following options:
_ALL_ describes all currently defined macro variables, regardless of scope. This includes user-created global and local variables as well as automatic macro variables. Scopes are listed in the order of innermost to outermost.
_AUTOMATIC_ describes all automatic macro variables. The scope is listed as AUTOMATIC. All automatic macro variables are global except SYSPBUFF. See Chapter 12, "Macro Language Elements," and Chapter 13 for more information on specific automatic macro variables.
_GLOBAL_ describes all user-created global macro variables. The scope is listed as GLOBAL. Automatic macro variables are not listed.
_LOCAL_ describes user-created local macro variables defined within the currently executing macro. The scope is listed as the name of the macro in which the macro variable is defined.
_USER_ describes all user-created macro variables, regardless of scope. The scope is either GLOBAL, for global macro variables, or the name of the macro in which the macro variable is defined.

For example, consider the following program:

%let origin=North America;

%macro dogs(type=);
   data _null_;
      set all_dogs;
      where dogtype="&type" and dogorig="&origin";
      put breed " is for &type.";
   run;

   %put _user_;
%mend dogs;

%dogs(type=work)

The %PUT statement preceding the %MEND statement writes to the SAS log the scopes, names, and values of all user-generated macro variables:

DOGS   TYPE   work
GLOBAL   ORIGIN   North America

Because TYPE is a macro parameter, TYPE is local to the macro DOGS, with value work. Because ORIGIN is defined in open code, it is global.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.