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. 

hackathon24-white-horiz.png

Join the 2025 SAS Hackathon!

Calling all data scientists and open-source enthusiasts! Want to solve real problems that impact your company or the world? Register to hack by August 31st!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1457 views
  • 0 likes
  • 3 in conversation