Hello,
I want know a stored macro definition without run it. how to do it?
Thanks
%macro test666;
%put 111;
%put 222;
%mend test666;
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.
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.
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?
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.
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.