Sample 24972: Sending E-mail from a DATA Step
This example demonstrates how a SAS program running on z/OS can create a file,
and then send that file as an attachment to an e-mail message in a subsequent DATA step.
The key is the EMAIL access method:
- the FILENAME statement specifies that myfile is written with the EMAIL access method
- the FILE statement directs the DATA step output to myfile
The attachment generated in this example is an HTML file, but it could have been any type of output
supported by the ODS statement.
To run this example, you need to provide the e-mail addresses of the recipients, the
e-mail subject, the data set name of the attachment file , and the
e-mail body text. These options are highlighted in red.
The reply-to e-mail addresses are optional.
The parentheses around the e-mail addresses may be omitted if only one e-mail address is specified.
|
|
ods listing close;
/* --------------------------------------------------------
|
ODS Options |
html |
generates HTML output |
style |
style definition applied to output |
rs |
suppresses record separator
force new record for each HTML line
required for z/OS HTML files |
--------------------------------------------------------- */
ods html body=
"attachment file"
style=bluebg
rs=none;
proc print data=sashelp.class double;
where age in (13 14);
title 'Height and Weight for 13 and 14 Year Olds';
run;
ods html close;
ods listing;
/* --------------------------------------------------------
|
FILENAME Options |
type |
identifies e-mail body as plain text |
ct |
identifies attachment as HTML text |
ext |
extension to append to "attachment file" |
--------------------------------------------------------- */
filename myfile email
to=
("e-mailaddress1" "e-mailaddress2")
replyto=
("e-mailaddress3" "e-mailaddress4")
subject=
"Report you requested"
type="text/plain"
attach=(
"attachment file"
ct='text/html' ext='html');
data _null_;
file myfile;
put 'Here is the report of 13 and 14 year olds.';
run;
quit;
|
See the Results tab for the email message and its attachment.
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.
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.
E-mail Message: Sending E-mail from a DATA Step
Attachment
This example demonstrates how a SAS program running on z/OS can create a file, and then send that file as an attachment to an e-mail message in a subsequent DATA step.
Type: | Sample |
Topic: | SAS Reference ==> Statements ==> Data Access ==> FILENAME Third Party ==> Information Exchange ==> E-mail (SMTP) SAS Reference ==> DATA Step
|
Date Modified: | 2005-12-08 11:34:38 |
Date Created: | 2005-01-05 08:29:29 |
Operating System and Release Information
SAS System | Base SAS | z/OS | n/a | n/a |