我需要将 sas 日志文件中的错误导入 sas 数据集(以批处理模式执行时,即在 PuTTY 中(。可能吗?代码已包含:
data test;
infile "&l_path/&name..log" truncover;
input error_and_warning $2000.;
if index(_infile_, 'ERROR:') = 1 then output;
if index(_infile_, 'WARNING:') = 1 then output;
run;
是的,您可以像读取任何其他文本文件一样读取 SAS 日志文件。 如果要读取正在执行的程序的日志,则需要使用PROC PRINTTO"捕获"日志。
在 https://lexjansen.com/搜索
我找到了这个 https://www.mwsug.org/proceedings/2012/S1/MWSUG-2012-S101.pdf
还有很多。
假设文件名"&l_path/&name..日志"是正确的,我认为这应该有效。 如果没有错误或警告,数据 TEST 将具有零 obs。
data test;
infile "&l_path/&name..log" truncover;
input error_and_warning $2000.;
if index(_infile_, 'ERROR:') = 1 then output;
if index(_infile_, 'WARNING:') = 1 then output;
run;
我想我已经解决了您说它在EG中有效但不适用于批处理的问题,这是因为批处理中的选项不同,并且扫描日志的数据步骤未执行。 您需要在数据步骤之前设置 OBS=MAX 和 NOSYNTAXCHECK 来扫描日志,如本例所示。
1 options generic=1;
2
3 filename FT12F001 temp;
4 proc printto log=FT12F001;
5 run;
NOTE: PROCEDURE PRINTTO used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
11 options obs=max syntaxcheck=0;
12 data errbase;
13 infile FT12F001 length=l;
14 input line $varying256. l;
15 if line eq: 'ERROR' then output;
2 The SAS System 06:17 Wednesday, September 26, 2018
16 putlog _infile_;
17 run;
NOTE: The infile FT12F001 is:
(system-specific pathname),
(system-specific file attributes)
NOTE: PROCEDURE PRINTTO used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
6 data x;
7 y eq x;
_
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
8 run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: SAS set option OBS=0 and will continue to check statements. This might cause NOTE: No observations in data set.
WARNING: The data set WORK.X may be incomplete. When this step was stopped there were 0 observations and 0 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
9 proc printto;
10 run;
NOTE: 24 records were read from the infile (system-specific pathname).
The minimum record length was 0.
The maximum record length was 118.
NOTE: The data set WORK.ERRBASE has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
ERROR: Errors printed on page 1.
NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414
NOTE: The SAS System used:
real time 3.88 seconds
cpu time 0.09 seconds