Hello,
How could we put the log in both log window and external file when we run a program in EG?
Thanks in Advance!
It would be nice if this was as easy as specifying the ALTLOG option to write the log to a file. Unfortunately, you can't specify ALTLOG during a SAS session. If you think SAS should change that, please upvote: https://communities.sas.com/t5/SASware-Ballot-Ideas/Allow-ALTLOG-to-be-specified-on-OPTIONS-statemen...
That said, a workaround I sometimes use it to use PROC PRINTTO to send the log to a file, then when I want to see the log I set PROC PRINTTO back to log=log, and stream the logfile back to the log window. Something like:
*send log to file ;
filename logfile "%sysfunc(pathname(work))/mylog.log" ;
proc printto log=logfile new ;
run ;
*main stuff;
proc means data=sashelp.shoes ;
run ;
*read the log back into the log window ;
proc printto log=log;
run;
data _null_;
infile logfile;
input;
putlog _infile_;
run;
It would be nice if this was as easy as specifying the ALTLOG option to write the log to a file. Unfortunately, you can't specify ALTLOG during a SAS session. If you think SAS should change that, please upvote: https://communities.sas.com/t5/SASware-Ballot-Ideas/Allow-ALTLOG-to-be-specified-on-OPTIONS-statemen...
That said, a workaround I sometimes use it to use PROC PRINTTO to send the log to a file, then when I want to see the log I set PROC PRINTTO back to log=log, and stream the logfile back to the log window. Something like:
*send log to file ;
filename logfile "%sysfunc(pathname(work))/mylog.log" ;
proc printto log=logfile new ;
run ;
*main stuff;
proc means data=sashelp.shoes ;
run ;
*read the log back into the log window ;
proc printto log=log;
run;
data _null_;
infile logfile;
input;
putlog _infile_;
run;
Hi Quentin,
Thanks for the solution.
Mushy
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.