BookmarkSubscribeRSS Feed
sasbasls
Calcite | Level 5

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


5 REPLIES 5
PGStats
Opal | Level 21

Are those log files from SAS?

PG
sasbasls
Calcite | Level 5

Yes...SAS logs

PGStats
Opal | Level 21

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

PG
Ksharp
Super User

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

PGStats
Opal | Level 21

Thanks Ksharp for the colon modifier. I learned something. - PG

PG

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1624 views
  • 1 like
  • 3 in conversation