BookmarkSubscribeRSS Feed
Krishna123
Calcite | Level 5

Hello

 

I am looking for a code that will list errors, warnings, and notes at first page of the log. Here is an example I copied from sas training practice exercise.

 

Errors, Warnings, Notes

> Errors (2)

> Warnings (5)

> Notes (7)

 

 

I appreciate your help.

 

Krishna

5 REPLIES 5
Quentin
Super User
I'm not quite sure what you mean? Do you mean you are looking for a log scanner (a program that will read in a log file and parse it, counting the number of errors/warnings/notes found)?
BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
Steelers_In_DC
Barite | Level 11

What you are describing sounds like the log summary in Enterprise Guide.  If you have the new version go to 'view' and select 'log summary'.  It is a new feature and will not be available with older versions.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

However, as this is posted in Base SAS section and not Enterprise Guide, its safe to assume she wants someone to provide the code for a logchecker.  Unfortunately this isn't a question, its is more a work order.  I have develope several of these in different languages and they boil down to a few simple steps:

- Read the text file in.

- Keep a variable which counts occurences of ERROR, WARNING, NOTE.  And the line number of each in the text file.

- Report the above out.

 

How you do that is really up to you.  I would also note that the those three sections may not capture everything you want to look at however, my logchecks pick out a number of other strings which I would want to look at, so I pick out errors and warnings, and then search for particulars, for instance uninitialised.

Reeza
Super User
That actually looks like SAS Studio/SAS UE. I think the OP should clarify the requirements.

Krishna123,

If you are running BASE SAS you can use the logic in the code below to create a data set that will contain the message of all errors found in your SAS log. The proc printto creates a copy of the log in the file specified by log=, then the data step reads that log file. You will need to create counters for errors, warnings and notes that are found in the log file. I suggest you use the end= option on the set statement and output only during the last iteration of the data step. This way your data set will just have the final value of your counter variables.

 

If you want the counters at the beginning of the log file you will need to use a data _null_ step, read the log file and write out to the file when _n_=1, the final value of your counters.

 

I hope this will help you get started.

Michelle

 

proc printto log='c:\1test\mylog.txt' new;
data test;
input x1 x2 x3;
cards /*no semicolon*/
1 2 3
4 5 6
;
proc print;
run;
proc printto log=log;
run;
data logtest;
infile 'c:\1test\mylog.txt' truncover;
input test $5. @;
if test='ERROR' then do;
input @6 msg $76.;
output;
end;
run;
proc print data=logtest;
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
  • 5 replies
  • 1101 views
  • 0 likes
  • 6 in conversation