%macro logclean;
DM 'log; "clear";';
run;
quit;
%mend;
%macro logcheck(p);
*日志错误信息检查,
注:在不跟参数的时候,将清除日志;
加参数1,怎保留日志;
DM 'LOG; log; FILE "y:\temp\check.log" replace;';
*注意修改日志保存的位置,并且同时修改下面data步的infile语句;
run;
%if &p=1 %then;
%else %do;
DM 'log; "clear";';
run;
quit;
%end;
%put CHECK at &systime ####################################################################;
*data logcheck;
data _null_;
infile "y:\temp\check.log" end=last;
retain line 0;
input Key$ @@;
line+1;
if line=1 then put "==================================================================================";
if Key in ( "ERROR:","ERROR","WARNING:" ) then do;
input Desc & $100.;
Put key= desc;
output;
end;
else if key="CHECK" then do;
input desc & $10.;
put "Above was check " desc "---------------------------------------------";
put;
end;
else input key $;
run;
%mend;
输出结果举例:
2820 %logcheck(1)
CHECK at 10:17 ####################################################################
NOTE: Infile "y:\temp\check.log" 是:
文件名=y:\temp\check.log,
RECFM=V,LRECL=256
==================================================================================
Key=ERROR: 编号的变量列表中 (s1-d) 数字后缀缺失。
Key=ERROR: 为数组 s 指定的维定义的变量过少。
Key=ERROR 400-185: SUM 语句要求数值表达式。
Key=WARNING: 没有找到列表 s1-s10000 中的所有变量。
Key=WARNING: 数据集 WORK.B 可能不完整。该步停止时,共有 0 个观测和 0 个变量。
Key=WARNING: 数据集 WORK.B 由于该步已停止,而没有被替换。
NOTE: 从 Infile "y:\temp\check.log" 中读取了 265 条记录。
最小记录长度是 0。
最大记录长度是 110。
NOTE: INPUT 语句到达一行的末尾,SAS 已转到新的一行。
NOTE: “DATA 语句”所用时间(总处理时间):
实际时间 0.01 秒
CPU 时间 0.01 秒
联系客服