Outputting Macro Generated Code to a File Using MPRINT
A useful technique when debugging complicated macros, is to route all macro generated code to a file by using the MPRINT and MFILE options. The advantage of this over just using MPRINT and looking at the log window, is that the file only contains the code written by the macro and is free of clutter such as messages, printed values, logic flows etc.
filename mprint 'macro.txt'; options mprint mfile;
%* Your SAS Code;