I'm trying to debug code used in a SAS program, but the program uses macros from a permanent library. I can't find the code that created the macros and I don't have access to the person who created the original library. I know that option mprint;
will show me the lines of code that the macro executes, but I would like to see all of the code that a macro uses so that I can more easily debug it. In other words, I would like to have all the information that would be available to me if I had the original program that generated the macros. Is that possible?
There are two possible ways you could be executing a SAS macro from a permanent library. Either you are using an autocall macro, or a stored compiled macro.
An autocall macro would mean you do have access to the source, because it's simply a .sas file with the name of the macro as the name of the file. You can %include the file and see the full text, assuming you know which directory it is in (you can have many autocall libraries). So if your SASAUTOS
directory is c:\sas\macros\
, and you are calling %mymacro()
, then you could execute
%include "c:\sas\macros\mymacro.sas";
which would include the pre-compiled text, and as long as you have the source2
option enabled, it will print to your log.
A stored compiled macro can be viewed only if it was compiled with the SOURCE
option. If it was not, then you cannot retrieve the macro source code (without having access to the program that created the SCM).
If it was compiled with SOURCE
, then you can use the %COPY
macro statement to copy the source code from the SCM to your log:
%copy mymacro / SOURCE;
More details are available in the SAS documentation, or from the excellent paper Ways to Store Macro Source Codes and How to Retrieve Them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With