另一种可能是将日志重定向到文件。例子:
%let logPath = d:\sas.log;
/* Delete the old log */
data _null_;
logFile = "mylog";
rc = filename(logFile,"&logPath");
if rc = 0 and fexist(logFile) then
rc = fdelete(logFile);
rc = filename(logFile);
run;
option nonotes nosource;
/* Redirect log to file */
proc printto log = "&logPath";
run;
%put >> File logging started <<;
%put ERROR: An error occured (macro);
%put WARNING: A warning occured (macro);
data _null_;
put "ERROR: An error occured inside my data step";
run;
%put >> File logging ended <<;
/* Turn standard logging on again */
proc printto;
run;
option notes source;
%put NOTE: Back to session log;