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 '[email protected]' 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