This sample uses new SAS 9.2 macro variables: &SYSERRORTEXT and &SYSWARNINGTEXT. These new macro variables contain the error and warning (at the time the macro variables are referenced) that were generated within a SAS program.
&SYSERR is also used to determine the return code of the step in question. One thing to remember about &SYSERR, it gets reset after each step boundary. &SYSCC could be used as it holds the last return code and is not reset at each step boundary.
A macro is invoked, checking the return code for the current step, and if a non-zero return code is set, e-mail is sent with the appropriate error and or warning message.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
filename myfile email
to="INSERT YOUR EMAIL ADDRESS HERE"
subject= "Error in Report"
type="text/plain";
%macro errmail;
%if &syserr ne 0 %then %do;
data _null_;
file myfile;
put 'Your job received the following ERROR/WARNING message:';
put;
put 'ERROR was:';
put "&syserrortext";
put;
put 'WARNING was:';
put "&syswarningtext";
run;
%end;
%mend errmail;
data one;
a;
run;
%errmail
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
The following is sent in an e-mail message: Your job received the following ERROR/WARNING message: ERROR was: 180-322: Statement is not valid or it is used out of proper order. WARNING was: The data set WORK.ONE may be incomplete. When this step was stopped there were 0 observations and 0 variables.
Type: | Sample |
Date Modified: | 2009-07-17 13:40:52 |
Date Created: | 2009-07-17 12:28:31 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | Base SAS | z/OS | 9.2 TS1M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS1M0 | |||
Microsoft Windows XP 64-bit Edition | 9.2 TS1M0 | |||
Microsoft® Windows® for x64 | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Standard Edition | 9.2 TS1M0 | |||
Microsoft Windows XP Professional | 9.2 TS1M0 | |||
Windows Vista | 9.2 TS1M0 | |||
64-bit Enabled AIX | 9.2 TS1M0 | |||
64-bit Enabled HP-UX | 9.2 TS1M0 | |||
64-bit Enabled Solaris | 9.2 TS1M0 | |||
HP-UX IPF | 9.2 TS1M0 | |||
Linux | 9.2 TS1M0 | |||
Linux for x64 | 9.2 TS1M0 | |||
OpenVMS on HP Integrity | 9.2 TS1M0 | |||
Solaris for x64 | 9.2 TS1M0 |