Reading sas log file dynamically in batch mode

Reply
Contributor
Posts: 30

Reading sas log file dynamically in batch mode

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;

Super User
Posts: 13,321

Re: Reading sas log file dynamically in batch mode

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.

 

 

 

 

Contributor
Posts: 30

Re: Reading sas log file dynamically in batch mode

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.

 

 

 

Super User
Posts: 13,321

Re: Reading sas log file dynamically in batch mode


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.

 

Super User
Posts: 3,857

Re: Reading sas log file dynamically in batch mode

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. 

Ask a Question
Discussion stats
  • 4 replies
  • 101 views
  • 0 likes
  • 3 in conversation