BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sun538
Obsidian | Level 7

Hi,

 

I need to send an email to some body about the status of the main SAS code execution, such that if any error occurs, it send an email and inform that. I used the following macro at the end of my code:

 

  %macro send_mail;
   filename mymail email 'ABC@gmail.com' subject='Status';
     %if &syscc>0 %then %do;
       data _null_;
         file mymail;
         put 'An ERROR has occurred in the code';
       run;
     %end;
     %else %do;
       data _null_;
         file mymail;
         put 'The job ran to completion';
       run;
     %end;
   %mend;
   %send_mail

However, it sends an error email (An ERROR has occurred in the code) even when there is no error in the main body of my code. Can you please let me know why it happens and how to resolve it?

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

Do you have any WARNINGs in the log?  SYSCC is set to 4 when there is a warning.  So if you want to flag just errors, try >4 for a check.

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!

View solution in original post

4 REPLIES 4
ChrisHemedinger
Community Manager

Do you have any WARNINGs in the log?  SYSCC is set to 4 when there is a warning.  So if you want to flag just errors, try >4 for a check.

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
sun538
Obsidian | Level 7
Many Thanks Chris. Yes, I have some warnings in the log. I changed it to &SYSCC >4 and works fine. Great. Thank you. So, there is no error type that set SYSCC a number between 0 and 4, is that correct?
ChrisHemedinger
Community Manager

Yes, for example see https://support.sas.com/kb/35/553.html.

 

But I agree with @Kurt_Bremser -- you should resolve the warnings too to avoid issues.  Sometimes warnings are an indicator of a problem that could cause unexpected results, even if not a SAS error.

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
Kurt_Bremser
Super User

The only thing you need to change is this:

put 'An ERROR has occurred in the code';

to this:

put 'An ERROR or WARNING has occurred in the code';

Any run that ends with SYSCC ne 0 is not acceptable, and the code needs to be fixed, or any other cause (e.g. wrong input data, wrong time to start the code etc) straightened out.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 839 views
  • 3 likes
  • 3 in conversation