BookmarkSubscribeRSS Feed
Deepti44
Fluorite | Level 6

Hi,

 

Im trying to read log file " dynamically " in batch mode(see below code) , but coudnt able to determine the ERRORS.when i run the same below code via sas EG front end it can able to determine the ERRORS. any idea what is going wron in batch mode.

 

/*EXTRACT ERRORS FROM LOG FILE AND SEND EMAIL */

data my_log;
infile "&LOGDIR." truncover;
input a_line $200.;
if index(a_line, 'ERROR:') >0
/*or*/
/*index(a_line, 'WARNING') > 0*/
then output;
/**/
/*if index(a_line, 'ERROR:') > 0 */
/*then abort 255;*/
run;

4 REPLIES 4
ballardw
Super User

Is the log file for match mode actually written to "&logdir"? Batch mode may well write the log to a different location depending on how the batch program is started. Check the parameters of the batch program that starts the job.

 

 

 

 

Deepti44
Fluorite | Level 6

yes it written to & logdir.

 

I'm getting below  ERROR when i execute in batch mode.

 

ERROR: At least one file associated with fileref MYLOG is still in use.

 

is there a way i can read log dynamiccay while execution in batch mode.

 

 

 

ballardw
Super User

@Deepti44 wrote:

yes it written to & logdir.

 

I'm getting below  ERROR when i execute in batch mode.

 

ERROR: At least one file associated with fileref MYLOG is still in use.

 

is there a way i can read log dynamiccay while execution in batch mode.

 

 

 


That is because SAS still has the log open to write to. You might investigate Proc Printto with the log option to write the log up to the point you want to read it.

Proc printto log='<log file name and location goes here>';

run;

<other code generating log entries>

/* this ends sending to that specific log file*/

Proc printo;

run;

Then the data step to generate your report but read the file on the Printo statement.

 

SASKiwi
PROC Star

Why are you trying to capture a batch job's warnings and errors while it is still running? Even if you can find a way to do it, you won't be able to capture all of them until the job has completed.

 

Personally I find it a lot easier to use the scheduler's functionality to automatically send an email if the job return code is not zero. Any warning or error in the SAS log will trigger a non-zero return code so you don't need to read the log at all. 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 676 views
  • 0 likes
  • 3 in conversation