SAS: Print to Log AND View Live Log Window Simultaneously

六月ゝ 毕业季﹏ 提交于 2020-01-02 18:33:09

问题


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?


回答1:


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.




回答2:


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)



来源:https://stackoverflow.com/questions/35609395/sas-print-to-log-and-view-live-log-window-simultaneously

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!