BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Mushy
Quartz | Level 8

Hello,

 

How could we put the log in both log window and external file when we run a program in EG?

 

Thanks in Advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

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;

 

View solution in original post

2 REPLIES 2
Quentin
Super User

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;

 

Mushy
Quartz | Level 8

Hi Quentin,

 

Thanks for the solution.

 

Mushy

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 997 views
  • 3 likes
  • 2 in conversation