DATA Step, Macro, Functions and more

How to display a macro definition without running it

Reply
Regular Contributor
Posts: 241

How to display a macro definition without running it

Hello, 

 

I want know a stored macro definition without run it. how to do it?

 

Thanks

 

 

 

%macro test666;
%put 111;
%put 222;
%mend test666;

Super User
Posts: 11,343

Re: How to display a macro definition without running it

Posted in reply to GeorgeSAS

Basically if the macro was not created with the STORE and SOURCE options on the %macro statement, which requires the System option  MSTORED and a permanent library referenced in the SASMSTORE option to be set you can't.

 

%copy can recover the source if the macro was compiled with the option.

 

options  mstored SASMSTORE=fp;
%macro test666/ store source;
%put 111;
%put 222;
%mend test666;
%copy test666/ source;

The above code sets the option mstored to allow storage, SASMSTORE=FP says that location in in MY permanent library FP. You would use your library.

 

The options are set on the macro state and the %copy will write this to the LOG:

 %copy test666/ source;
%macro test666/ store source;
%put 111;
%put 222;
%mend test666;

If the question was asked because someone did not save the source code you are basically out of luck. Note that the SAS documentation emphasizes to Save the code.

 

Regular Contributor
Posts: 241

Re: How to display a macro definition without running it

While the option in my SAS system is :
NOMSTORED
Without changing it, what should I do then?
Super User
Posts: 11,343

Re: How to display a macro definition without running it

Posted in reply to GeorgeSAS

The example code shows everything you need to do to create the macro catalog in the library and then recover the source.

The OPTIONS statement before the %macro statement shows the details.

Regular Contributor
Posts: 241

Re: How to display a macro definition without running it

[ Edited ]

How if the macro was a stored macro:

"D:\MYSAS\sasmacro\test666.sas"
content of test666.sas :
%macro test666;
%put 111;
%put 222;
%mend test666;

The option in config file: OPTIONS SASAUTOS=("D:\MYSAS\sasmacro");

 

In this case, I want to know/display the macro definition, but I am not the author of the macro. I don't know the content.how to display the definition then?

Ask a Question
Discussion stats
  • 4 replies
  • 141 views
  • 0 likes
  • 2 in conversation