Desktop productivity for business analysts and programmers

Working with code and messages errors

Reply
N/A
Posts: 0

Working with code and messages errors

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
N/A
Posts: 0

Re: Working with code and messages errors

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
SAS Super FREQ
Posts: 8,820

Re: Working with code and messages errors

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
N/A
Posts: 0

Re: Working with code and messages errors

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.
N/A
Posts: 0

Re: Working with code and messages errors

Hi Chuck, dkvj and Cynthia@sas

Thanks for your help!

Best Regards
Fernando Santos Message was edited by: FernandoSantos
Ask a Question
Discussion stats
  • 4 replies
  • 112 views
  • 0 likes
  • 2 in conversation