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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 679 views
  • 0 likes
  • 2 in conversation