Can I redirect the SAS listing desitination to the log?
Can I redirect the SAS Listing destination to the log?
Alternatively, can I redirect the Listing destination to an external file and keep it open in the SAS windowing environment? I know I can use PROC PRINTTO to write it out to an external file, but this prevents the output also appearing in the window.
Isn't it just a simple case of:
ods listing file="myfile.txt";
... and if you haven't already got ods html turned on:
This will send the listing to the specified file instead of the 'Output' window, and the ODS results from any procs will go to your 'Results' window.
I know this setup has actually cause me issues in the path with creating and naming images as I didn't realise the listing destination was open in addition to my ODS destination and I was getting duplicated images until I turned listing off.
I've since discovered the -altprint option which does exactly what I want.
If you wish to change the output/lst dynamically during the course of a program to write to the log instead of a separate location then the following may be useful. (IE. this make both LOG and LST go to LOG)
It works in BATCH (NODMS) mode but will not work in interactive (DMS) mode.
I'm not sure how backwardly compatible this is, but it works in 9.4.
/* redirect OUTPUT/LST to LOG by going to the SASHELP VEXTFL to get the log fileref (ONLY WORKS IN BATCH)*/ %let ISBATCH=%sysfunc(getoption(dms)); %if &ISBATCH = NODMS %then %do; PROC SQL outobs=1 noprint; SELECT t1.fileref INTO :LOG_FILEREF FROM SASHELP.VEXTFL t1 where t1.xpath like '%.log%'; QUIT; %put NOTE: LOG_FILEREF=&LOG_FILEREF; proc printto print=&LOG_FILEREF; run; %end;