redirectLog
The width of the output is set to the maximum of 256 characters.
The filename looks like
YYYY-MM-DD_HH-MM-SS-PID
(PID is the process identifier as identified with
&sysobjid
.
%macro tq84_redirectLog(logDir);
options linesize=256
nocenter /* Setting nocenter so that output of proc sql is put to left side */
;
%local logFile;
%let logFile="&logDir/%sysfunc(putn(%sysfunc(date()), yymmddd10.))_%tq84_reReplace(%sysfunc(putn(%sysfunc(time()), tod8.)), :, -)_&sysjobid";
/* The order of the proc printo is important
(https://stackoverflow.com/a/47515843/180275) */
proc printto log = &logFile; run;
proc printto print = &logFile; run;
%mend tq84_redirectLog;
In order for the log file to be immediately flushed, the
logparm option should be set to
write=immediate
in a
config file.