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

sas-innovate-2024.png

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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