BookmarkSubscribeRSS Feed
dcooper210
Calcite | Level 5

I have a SAS job that is scheduled to run once a month.  For the past several months it has thrown the following error(s):

 

ERROR: CLI error trying to establish connection: FATAL 1: database connection refused

ERROR: Error in the LIBNAME statement.

 

This is because the server changed without my knowledge.  I would like to have these errors sent to me if possible.  I tried this code:

 

%macro send_mail;

filename mymail email 'dsmith2@somewhere.com' subject='ERROR in job';

%if &syscc>0 %then %do;

 

data _null_;

%put &syscc;

 

file mymail;

put 'An ERROR has occurred in the SAS datasets code';

 

run;

%end;

%else %do;

 

data _null_;

file mymail;

put 'The SAS datasets job ran to completion';

 

run;

%end;

%mend;

 

%send_mail

 

I put it right after the libname statement.  It sends an email but the message is "The SAS datasets job ran to completion."  I understand I might have to have the program run, save the log, and parse it for the error and then run the program again. 

 

How does this work with a scheduled job?  Do I need to put it on the scheduler twice?

 

Thanks,

Debbie

 

1 REPLY 1
SASKiwi
PROC Star

What scheduler are you using? Some schedulers will automatically email you if there is an error. We use this functionality with the LSF scheduler and it means you don't have to code anything.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1 reply
  • 621 views
  • 0 likes
  • 2 in conversation