This is what I do: 1) Pull all Logs from Folder 2) Convert to Table 3) Look for ERROR and remove known issues 4) Combine Tables 4) Create Run Log Email %LET TDATA = U:\SAS\Morning logs\ ;
%PUT &TDATA = TDATA;
filename pipedir pipe ' dir "U:\SAS\Morning logs"/s' lrecl=5000;
data indata (keep = fn date time ampm Y);
infile pipedir truncover;
input line $char1000.;
length directory $1000;
retain directory;
if line =' ' or
index(upcase(line),'<DIR>') or
left(upcase(line))=:'VOLUME' then
delete;
if left(upcase(line))=:'DIRECTORY OF' then
directory=left(substr(line,index(upcase(line),'DIRECTORY OF')+12));
if left(upcase(line))=:'DIRECTORY OF' then
delete;
date=input(substr(line,1,10),?? mmddyy10.);
TIME = Input(substr(line,12,5),??TIME.);
AMPM = Input(substr(line,18,2), $3.);
NAME = INPUT(SUBSTR(LINE,40,3),$4.);
NAME2 = INPUT(SUBSTR(LINE,60,7),$8.);
fn = INPUT(SUBSTR(LINE,40,31),$32.);
call
symput (
'num_files'
,_n_);
call symput (
'filein'
,fn);
format date mmddyy10.;
FORMAT TIME
TIME.;
Y=1;
IF DATE NE TODAY() THEN DELETE;
IF SCAN(FN,-1) NE 'log' THEN DELETE;
if fn = 'ERROR CHECK.log' then delete;
proc sort ;
by descending DATE TIME;
run;
DATA X;
SET INDATA;
BY Y;
RETAIN C ;
C=C+1;
IF FIRST.Y THEN C=1;
RUN;
data _null_;
set X;
if c = 1 then call symput('fn1',FN);
if c = 2 then call symput('fn2',FN);
if c = 3 then call symput('fn3',FN);
if c = 4 then call symput('fn4',FN);
if c = 5 then call symput('fn5',FN);
if c = 6 then call symput('fn6',FN);
if c = 7 then call symput('fn7',FN);
if c = 8 then call symput('fn8',FN);
if c = 9 then call symput('fn9',FN);
if c = 10 then call symput('fn10',FN);
if c = 11 then call symput('fn11',FN);
if c = 12 then call symput('fn12',FN);
if c = 13 then call symput('fn13',FN);
if c = 14 then call symput('fn14',FN);
if c = 15 then call symput('fn15',FN);
if c = 16 then call symput('fn16',FN);
if c = 17 then call symput('fn17',FN);
/*
if c = 18 then call symput('fn18',FN);
if c = 19 then call symput('fn19',FN);
if c = 20 then call symput('fn20',FN);
if c = 21 then call symput('fN21',FN);
*/
run;
Filename in_e "&tdata\&fn1";
data temp;
infile in_e;
input msg $ cont $200.;
run;
data temp1;
set temp;
x= "&tdata\&fn1" ;
if index(cont, "ERROR:" ) ge 1 then output;
run; Results Attached
... View more