BookmarkSubscribeRSS Feed
GeorgeSAS
Lapis Lazuli | Level 10

Hello, 

 

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

 

Thanks

 

 

 

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

4 REPLIES 4
ballardw
Super User

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.

 

GeorgeSAS
Lapis Lazuli | Level 10
While the option in my SAS system is :
NOMSTORED
Without changing it, what should I do then?
ballardw
Super User

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.

GeorgeSAS
Lapis Lazuli | Level 10

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?

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2747 views
  • 0 likes
  • 2 in conversation