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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.