hi,
I need to check multiple log files if they are created today and to check if no error exists in log files without manually opening log files. Can this be done using SAS statements ?
thanks,
basesas
Are those log files from SAS?
Yes...SAS logs
Assuming your log file all sit in the same directory under Windows, you could do :
%let logPath=YOUR_LOG_PATH;
filename toto PIPE "DIR ""&logPath.\*.log"" /n/o-d/t:c " console=min;
data test(keep=logFile);
retain todayStr;
length logFile $200;
infile toto;
if _n_ = 1 then todayStr = put(today(),yymmddd10.);
input;
if substrn(_infile_,1,10)=todayStr then do;
logFile = substrn(_infile_,37);
output;
end;
run;
filename toto dummy;
data _null_;
set test;
logPath = cats("&logPath.\", logFile);
do until (_eof);
infile toto filevar=logPath end=_eof;
input;
if substrn(_infile_,1,6) = "ERROR:" then do;
put "Error found in log file: " logFile " : " _infile_;
_eof = 1;
end;
end;
run;
not fully tested... Not likely to work on UNIX - PG
Here is the code I wrote before.
data _null_; infile '/spds_data6/temp/jh.txt' dlm=' ' length=len expandtabs; input row $varying200. len; if left(row) in: ('ERROR' 'WARNING') then put row;run;
Ksharp
Thanks Ksharp for the colon modifier. I learned something. - PG
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.