02.05.2013 Views

SAS(R) 9.1.3 Companion for z/OS

SAS(R) 9.1.3 Companion for z/OS

SAS(R) 9.1.3 Companion for z/OS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Directing <strong>SAS</strong> Log and <strong>SAS</strong> Procedure Output Sending Procedure Output as E-Mail 139<br />

data _null_;<br />

file reports;<br />

infile cards eof=lastobs;<br />

length name dept $ 21;<br />

input name dept;<br />

put ’!EM_TO!’ name;<br />

/* Assign the TO attribute */<br />

put ’!EM_SUBJECT! Report <strong>for</strong> ’ dept;<br />

/* Assign the SUBJECT attribute */<br />

put name ’,’;<br />

put ’Here is the latest report <strong>for</strong> ’ dept ’.’;<br />

if dept=’marketing’ then<br />

put ’!EM_ATTACH!’ "userid.market.report";<br />

else<br />

/* ATTACH the appropriate report */<br />

put ’!EM_ATTACH!’ "userid.devlpmnt.report";<br />

put ’!EM_SEND!’;<br />

/* Send the message */<br />

put ’!EM_NEWMSG!’;<br />

/* Clear the message attributes */<br />

return;<br />

lastobs: put ’!EM_ABORT!’;<br />

/* Abort the message be<strong>for</strong>e the */<br />

/* RUN statement causes it to */<br />

/* be sent again. */<br />

datalines;<br />

Susan marketing<br />

Jim marketing<br />

Rita development<br />

Herb development<br />

;<br />

run;<br />

The resulting e-mail message and its attachments are dependent on the department<br />

to which the recipient belongs.<br />

Note: You must use the !EM_NEWMSG! directive to clear the message attributes<br />

between recipients. The !EM_ABORT! directive prevents the message from being<br />

automatically sent at the end of the DATA step. R<br />

Sending Procedure Output as E-Mail<br />

E-mail can be used to send procedure output. ODS HTML procedure output must be<br />

sent with the RECORD_SEPARATOR (RS) option set to NONE. For z/<strong>OS</strong>, ODS produces<br />

an HTML stream with embedded record-separator characters, by default. When the RS<br />

option is set to NONE, ODS writes one line of HTML at a time to the file. Be sure that<br />

the file’s record length is large enough to accommodate the longest HTML line.<br />

The following section contains examples that illustrate how to send ODS HTML and<br />

graph output in the body of an e-mail message and also as attachments to e-mail.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!