09-19-2012 03:12 PM
'2E'x is a period and '0D'x is a carriage return. Perhaps it is looking for a period at the end of line? Although that would assume that log was written on Windows and then re-read on Unix or with settings to prevent SAS from stripping the CR.
I looked briefly at the code in the paper and it is probably not going to find all of the error messages.
Normally I search for lines that start with ERROR. This will eliminate many false positives caused by MPRINT, SOURCE or SOURCE2 settings echoing the source code to the log. Also SAS can sometimes insert text between the ERROR at the beginning of the line and colon (':') before the error message.
07-09-2013 03:51 PM
Realised this is almost a year-old thread, but think it's worth replying.
Tom, I think you are right, it does indeed search for combination of the full stop and carriage return. Unfortunately, in some cases error goes onto a new line, which would break this macro a little. Also good spot on the environment differences, was sure to baffle me for a while.
I'm trying to augment/change code a bit, so that it could read multiple log lines, if any of the text triggers have been encountered.
Not really sure how, without reading heaps of sugi docs -- so if you have any pointers on this front, or have any more elegant solutions that would be greatly appreciated!
07-15-2013 06:21 AM
Not sure if that helps anyone, but I, inspired by the paper wrote something which i think is slightly more robust at picking up errors:
filename log "&logfile";
data de_log_output (drop=line_txt);
retain nline 0;
length line_txt FULL_TEXT $ 1000 TYPE $ 10 SUB_TYPE $ 100;
infile infl lrecl=200 pad;
if substr(_infile_, 1, 5) = "ERROR"
or substr(_infile_, 1, 7) = "WARNING"
or substr(_infile_, 1, 4) = "NOTE"
line_txt = _infile_;
if substr(_infile_, length(_infile_), 1) ne '2E'x then do;
line_txt = _infile_;
do while (substr(_infile_, length(_infile_), 1) ne '2E'x);
line_txt=catx(" ", line_txt, _infile_);
/*exclude non-error notes*/
if substr(line_txt, 1, 4) = "NOTE"
and (index(line_txt, 'The data set')=0
or index(line_txt, 'has 0 observations')=0)
/*define type and subtype*/
TYPE = compress(scan(line_txt, 1, " "), ":");
if index(line_txt, ",") and not(index(line_txt, "DROP,")) then do;
SUB_TYPE = substr(scan(line_txt, 1, ","), index(line_txt, ":") +2);
else if index(line_txt, "0 observations") then do;
SUB_TYPE = "Incomplete dataset (obs=0)";
else if index(line_txt, "Multiple lengths were specified for the BY variable")
SUB_TYPE = "BY variables have inconsistent LENGTHS";
else if index(line_txt, "The quoted string currently being processed") then do;
SUB_TYPE = "Unbalanced quote marks?";
else if index(line_txt, "Invalid data set name") then do;
SUB_TYPE = "No / invalid dataset name";
else if index(line_txt, "has never been referenced") then do;
SUB_TYPE = "Keeping, dropping or renaming non-existent variable";
else SUB_TYPE = "Other";
FULL_TEXT = line_txt;
by TYPE SUB_TYPE;
noprint nway n;
class TYPE SUB_TYPE;