The macro language %PUT statement, as document, "normally" posts / outputs macro processing diagnostic messages, including macro variable values, to the SAS log, however, yes, it is possible to re-direct the SAS-generated log to an external file using PROC PRINTTO.
Hi:
Something similar to this technique might work for you:
[pre]
** Use PROC PRINTTO to get ONLY list of Macro vars;
filename mylog "c:\temp\allmacvars.txt";
PROC PRINTTO log=mylog; run;
%put _all_;
PROC PRINTTO; run;
[/pre]
The PROC PRINTTO steps surround the %PUT _ALL_ -- so this will effectively capture what is written to the log as the result of the %PUT _ALL_ and then the log will return to normal after the second PROC PRINTTO.
You could, of course, put any number of specific %PUT statements in between the PRINTTO steps.