BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have a process in SAS with many data steps. I want to check the return code (rc) after which data step processing and if the rc is different to 0 then the system sends a e-mail with the code and message of error. How may I do this?
Thank you
4 REPLIES 4
deleted_user
Not applicable
To start with,

various return and status codes for SAS are available through predefined macro variables:

SYSERR, SYSFILRC, SYSLIBRC, SYSRC, SYSCC

SYSERR = "Contains a return code status set by some SAS procedures and the DATA step"

Check your SAS Macro Language Reference documentation for detailed descriptions.

Email is more involved, but can be done, I believe via the ODS system. I believe it requires an email account, password, access/knowledge of the email server. But, once set up , it is easy to compose and send an email from within SAS. Message was edited by: Chuck
Cynthia_sas
SAS Super FREQ
Hi:
Previous forum postings are available on the topic of ODS and email and email with the FILENAME email engine:
http://support.sas.com/forums/thread.jspa?messageID=6780᩼
http://support.sas.com/forums/thread.jspa?messageID=4421ᅅ
http://support.sas.com/forums/thread.jspa?messageID=5990ᝦ

and Tech Support has other examples posted. There is a documentation topic (listed in one of the above posts) that also outlines the various email methods.

cynthia
deleted_user
Not applicable
There are many resources to tell you how to send email from a SAS session, and you would do well to read widely among the available notes and papers.

A couple of traps are out there however. The first is that if you try to do something in a data step that causes a SAS error, like reference a file that doesn't exist, then SAS will set Obs to 0 and go into debugging mode. As a result, any subsequent step that tries to process data; like a Data _NULL_ to send an email, will not work. Be careful of the system return codes too, make sure you understand how each one works, and where it will not tell you what you think it does. Carefully Read The Factual Material.

The second issue to consider is the problem(s) caused by using an email client such as Outlook to send your email. Not only will you probably encounter their puerile "A program is trying to send email" message box, but you are prone to have your email address "Interpreted" by the Outlook address book. The general solution is to use SMTP to send the email but this opens some security issues with the Post Office, and is often not allowed by your system administrators.

You can solve each of these problems, but be aware that it may not be, or remain simple.
deleted_user
Not applicable
Hi Chuck, dkvj and Cynthia@sas

Thanks for your help!

Best Regards
Fernando Santos Message was edited by: FernandoSantos

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 937 views
  • 0 likes
  • 2 in conversation