2

I understand that PROC PRINTTO LOG="C:TEMP\SAS LOG.TXT" outputs the entire contents of a SAS program log, but this also essentially leaves the log window blank while the program is running and I am unable to view the 'live' progress of the SAS program so to speak.

I want to ultimately save the log for further review, but I also want to keep an eye on things as they're happening live when I'm running tests, etc. -- is there a way to print the log and keep the contents of the log live as they're happening simultaneously?

kstats9pt3
  • 799
  • 2
  • 8
  • 28
  • what type of system are you using and which SAS editor? – DomPazz Feb 24 '16 at 19:19
  • I'm running SAS 9.3 on Windows 7 64-bit and use the standard SAS editor window for programming purposes -- does that give you what you need? I apologize if my lingo is off. – kstats9pt3 Feb 24 '16 at 19:38
  • 1
    That's fine. Short answer is no, SAS only allows 1 stream for the log. I THINK you can script a IDE macro to save the contents of a window. So run your program, watch the log, and when done, hot key the save. Not 100% sure and I don't have to figure it out right now. Personally, in these situations I put the log to a file with `PRINTTO` and watch it in a text editor with periodic refresh. – DomPazz Feb 24 '16 at 19:42
  • Thanks for the insight @DomPazz, I was wondering what others might do in this case. I'll go ahead and do that -- I can't recall Notepad++ having a refresh button, so how do you go about that? – kstats9pt3 Feb 24 '16 at 19:52
  • I open my program, save my log to a file, using point and click and then run. The log is then saved to a text file and you can see it as it generates as well. – Reeza Feb 24 '16 at 19:53
  • 1
    Also, look into the ALTLOG specification. I'm not sure how to call it, but it seems that it should offer that functionality. http://support.sas.com/documentation/cdl/en/hostwin/63047/HTML/default/viewer.htm#n02cl0iq0k1fmxn11p83yirplodk.htm – Reeza Feb 24 '16 at 19:57
  • @Reeza, ALTLOG is a command line option (specify on SAS startup) that send a copy of the log to a file. That is probably the best solution. I didn't know it exists. – DomPazz Feb 24 '16 at 20:15
  • Can you throw command lines in SAS code, or do they have to be entered manually in the command bar? – kstats9pt3 Feb 24 '16 at 20:16
  • a raised this with sas support some years ago.. The ultimate response was no, it's not possible (in the programmatic / system options sense) – Allan Bowe Feb 24 '16 at 20:54

2 Answers2

0

If you are using Enterprise Guide or any of the EBI clients you could enable logging on the application server. This will give you a copy of the log along with your regular log. Won't work for Base SAS though..

Steps:

  1. Navigate to: [sasconfig]\Lev1\SASApp\WorkspaceServer
  2. Rename logconfig.xml to logconfig.xml.orig
  3. Rename Logconfix.trace.xml to logconfig.xml
  4. Restart the object spawner

EDIT: if you were happy to accept sequential - as opposed to simultaneous - logging, I'd recommend the approach outlined in the answer to this question (basically read the external log file back in and print to session log)

Community
  • 1
  • 1
Allan Bowe
  • 12,306
  • 19
  • 75
  • 124
0

I agree with @Reeza's suggestion to try -altlog. Unfortunately, this option needs to be specified when SAS is invoked. One way is to add a line to your SAS config file (mine is in C:\Program Files\SASHome\SASFoundation\9.4\nls\en\sasv9.cfg):

-altlog d:\junk\MySASaltlog.log

Each time you start SAS, it will write to MySASaltlog.log in addition to your log window. MySASaltlog.log is overwritten for each session. You have to jump through some hoops to generate a separate log for each session.

I think it would be great if you could specify altlog on an options statement during a SAS session, e.g.:

options altlog="d:\junk\MySASaltlog_%sysfunc(today(),yymmddn8)"; 

If you agree, please like / upvote my SAS ballotware idea that proposes this: https://communities.sas.com/t5/SASware-Ballot-Ideas/Allow-ALTLOG-to-be-specified-on-OPTIONS-statement/idi-p/219628

Another approach for PC SAS is to use the DM statement. Submitting the following statement will copy the content of the current log window to MyLog_YYYYMDD.log:

dm "log; file ""d:\junk\MyLog_%sysfunc(today(),yymmddn8).log"" replace;";

You could probably assign that command to a function key as well.

A last thought is to question why you want to save the log from an interactive SAS session. Most folks use interactive sessions to develop code. Then when they are done, they batch submit the program for the final production run. This has the benefit of starting with a clean SAS session, as well as writing a log file automatically. With that approach, it's rarely useful to save a log file from an interactive session.

Quentin
  • 5,960
  • 1
  • 13
  • 21