BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
vandhan
Fluorite | Level 6

I have some ABC macro.

 

I have called ABC macro with mprint option. I can see sas code of the complied macro with notes and etc.

 

I want clean code of that complied macro where I can edit code in between any step and run that code for my self.

 

 

please help.

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

If a macro is compiled with the source option, you can copy the code to a file:

option mstored sasmstore=sasuser;
%macro test/store source;
%put this is my macro;
%mend;

%copy test/source outfile='$HOME/sascommunity/test.sas';

or just to the log:

%copy test/source;

With the second method, you'll already have clean code for copy/pasting in the log:

28         %macro test/store source;
29         %put this is my macro;
30         %mend;
31         
32         %copy test/source;
%macro test/store source;
%put this is my macro;
%mend;

You find this in the documentation of the %COPY statement.

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

"I can see sas code of the complied macro with notes and etc." - you can see this in the log yes?

 

"I want clean code of that complied macro " - other than taking the log output and cleaning it up yourself, the best idea is to get the source text.  It is always best to get the source text (in fact its always best to keep macros as plain text files - this would not only make this question easier, but there are a number of issues with proprietary binary files - if you ever try to go 32bit-64bit or vice versa you will find out).

 

"where I can edit code in between any step and run that code for my self." - this does not make any sense, code is created before run time, if you need to have generic code, then you need macro coding or call execute.  However as you have not provided any information I cannot provide any further help.

Kurt_Bremser
Super User

If a macro is compiled with the source option, you can copy the code to a file:

option mstored sasmstore=sasuser;
%macro test/store source;
%put this is my macro;
%mend;

%copy test/source outfile='$HOME/sascommunity/test.sas';

or just to the log:

%copy test/source;

With the second method, you'll already have clean code for copy/pasting in the log:

28         %macro test/store source;
29         %put this is my macro;
30         %mend;
31         
32         %copy test/source;
%macro test/store source;
%put this is my macro;
%mend;

You find this in the documentation of the %COPY statement.

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
  • 2 replies
  • 1313 views
  • 0 likes
  • 3 in conversation