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?

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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