BookmarkSubscribeRSS Feed

It would be cool if a proc existed that output macro documentation of a compiled macro. Kind of like Proc Catalog but in addition to the current fields it provides – it included a more robust description (more than 40 characters) and included the list of keyword or positional parameters. Maybe even info like if the parameter is required, optional, default value if defaulted, example value, and an example macro call. Similar to Proc Contents where you can turn on/off the level of details requested - you can get a high-level list of tables & their values, and a detailed page of each individual table. It would be helpful if something similar existed for compiled macros.

Super User

If you need these features I recommend providing them as part of the macro definition(s). It is not that difficult to add a keyword parameter that defaults to "NO" or similar behavior that when you set to YES it provides the description you are requesting.


Some example with the %sganno macro supplied by SAS to help with statistical graphics annotate data set. When the macro compiles it includes a macro %sganno_help which you can call with the name of one of the component macros or ALL as the parameter to get help with the included data manipulation macros.


%annomac did something similar with the SAS/Graph device based annotate graphics help.


This might also partially conflict with the existing SECURE option when compiling macros.


Use of the SOURCE option would be a good idea if you have such concerns as then you can at least recover the code from the compilied macro. And of course make sure you have back ups of the original macro code.

Quartz | Level 8

ballardw thanks for the suggestion! I'll have to look into how that works for the macros you mentioned.


What I'm suggesting is an expansion to the information that's provided when executing a Proc Catalog procedure on the macro catalog. Currently, the catalog returns the macro name, type, create data, modified date, and description (limited to 40 characters). I thought it would be helpful if it could return more details regarding the compiled macros stored in the catalog. I use some of my compiled macros more than others so from time to time I forget what the parameters are or if any of them defaulted, etc.

Super User

brief example using positional parameter and setting a brief help description.

%macro dummy(dsn);
   %if &dsn=? %then %do;
   %put The macro dummy prints a data set if provided with 
a data set name in the first parameter or this text with a ?
as the first parameter.;
   %put example call: '%dummy(work.setname)';
   %goto Exit;
   proc print data=&dsn;


Yes this does use the not-liked-by-many-GOTO instruction.


Quartz | Level 8
Hey thanks for the example code!
Obsidian | Level 7
I see your "%goto" and suggest an "%else %do proc ..."
Jade | Level 19

@CJac73 wrote:

I see your "%goto" and suggest an "%else %do proc ..."


I think using %GOTO makes it a bit easier to add to existing macros.  However an exit via the "new" %RETURN statement would be even easier.  No need to create the labeled statement %EXIT: 

Rhodochrosite | Level 12

What do you mean? like Extended Attributes for MACROs, MACRO VARIABLES, formats, functions, etc.,  Yes. I like it!


I'd like to see something like this, say one could code this:


%MACRO Fubar(SNAFU1, SNAFU2)  /label="This function replaces datasets given by parameter SNAFU1 and replaces them with datasets in parm. SNAFU2";
  %addExtAttr(SNAFU1,Something bad);
  %addExtAttr(SNAFU2,Something that is still bad, but a little less so);
  %put stuff...;

  %addExtAttr(TARFU,its bad for this variable to have a value);

(Shout out to my computer science teachers who had those kinds of sense-of-humors.)


Anyway, somehow, not like this per se, but allow macros and macro variables to have labels that can be assigned, where the labels are added to the appropriate DICTIONARY tables which might be called back using.


proc sql;
 select name, 
    from dictionary.funcXattrs;