DATA Step, Macro, Functions and more

Log window and external file

Reply
Occasional Contributor
Posts: 6

Log window and external file

Is there a way to have the log information appear in the log window and have it output to an external text file.

Trusted Advisor
Posts: 1,607

Re: Log window and external file

You can always save the LOG window to a text file.

 

You can also use the ALTLOG option to cause this to happen automatically.

Regular Contributor
Posts: 212

Re: Log window and external file

[ Edited ]

Hi mate,

 

The SAS Log appears as standard in SAS Softwares, but in Enterprise Guide, if you need to

see the whole SAS Log history, you need to go to the process flow, click on project log and

click turn on to store the history of SAS Log in that session.

If you need to export the SAS Log use the proc printto or export by point-and-clicking.

 

proc printto log='use_a_macro_to_get_the_log_automatically.log';
run;

If you need this to happen automatically, then put this code into insert custom code after

submitted code.

 

Att

Occasional Contributor
Posts: 6

Re: Log window and external file

,

Thanks for the suggestions.

A little more detail from me would have helped.

I'm looking for a programmatic way to save the log file to an external text file.

And, if it is run interactively, to have the log also show in the log window.

I don't know if I can have my cake and eat it too by having the log automatically go to a text file and display in the log window.

From what I've read, it's one or the other.

Is this correct or can I have the log go to the window and a text file.

Trusted Advisor
Posts: 1,607

Re: Log window and external file

[ Edited ]

As I said, the ALTLOG option creates both the SASLOG in the LOG window, and a text file containing the SASLOG.

Regular Contributor
Posts: 212

Re: Log window and external file

[ Edited ]

Jean, a sas code to do this is the proc printto like i said.

 

See this link: http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/viewer.htm#a001330273.htm

 

Att

Trusted Advisor
Posts: 1,607

Re: Log window and external file

[ Edited ]

DartibaliRodrigo wrote:

Jean, a sas code to do this is the proc printto like i said.

 

See this link: http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/viewer.htm#a001330273.htm

 

Att


This does not meet the requirements stated. You don't get the log in BOTH the LOG window and in a text file. You only get the log in a text file.

 

The ALTLOG option does meet the requirements.

PROC Star
Posts: 1,227

Re: Log window and external file

Agree with the altlog suggestion.  If you're on PC SAS, you can also use DM commands to copy the log to a file, e.g. :

 

 dm "log; file ""%sysfunc(pathname(work))/__mylog.log"" replace;";

 

Will write the contents of the log window to a file named __mylog.log in your work directory.  I do this for quick log scanning during interactive sessions.

Super User
Posts: 3,101

Re: Log window and external file

I find it easier to run SAS programs in batch mode if I want a LOG file as it gets produced automatically. That way no code changes are required.

Ask a Question
Discussion stats
  • 8 replies
  • 260 views
  • 1 like
  • 5 in conversation