BookmarkSubscribeRSS Feed
Tej27
Calcite | Level 5

Hi, 

 

Is there a SAS code out there that can help me scan errors in a log file with the line number the errors occur?

for ex: check for errors, warnings and tells me what line number is that occuring.. 

 

Will appreciate any help!!

 

--Tej

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, I think EG or one of the other SAS products has a summary which gives a count for each WARNING, ERROR and NOTE.  I have developed a couple of these in both SAS and C#, it is a simple load text file and scan for elements you want to scan.  I will not provide you code as that is proprietary, but a couple of pointers.

data ...; 

  infile "<your_log>"...;

  input buffer $;

run;

 

data ...;

  set <dataset above>;

  if index(buffer,"ERROR") > 0 then...

run;

user24feb
Barite | Level 11

Gives the error description an the line of code:

 


Proc PrintTo Log="C:\Users\NAME\Desktop\Test_Log.Log" NEW;
Run;

Proc DO_NOT_EXIST_Print; Run; * create an error;
Proc DO_NOT_EXIST_Print; Run;
Proc DO_NOT_EXIST_Print; Run;

Proc PrintTo;
Run;

Data LogCheck;
  Infile "C:\Users\NAME\Desktop\Test_Log.Log" Delimiter='09'x Missover DSD Lrecl=32767;
  Informat LogLine $200.;
  Format LogLine $200.;
  Input Logline $;
  Length Codeline $10.;
  Retain CodeLine '.';
  CodeLine=IfC(NotDigit(Substr(LogLine,1,1)),CodeLine,Scan(LogLine,1,' '));
  If Logline=:"ERROR:" Then Output;
Run;

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
  • 2 replies
  • 1017 views
  • 1 like
  • 3 in conversation