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
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.