BookmarkSubscribeRSS Feed
G_I_Jeff
Obsidian | Level 7

Trying to accomplish one e-mail but get either two separate e-mails or missing data, depending on ODS statement placement:

options emailsys=SMTP;
options emailhost='mail.from.me.host';
filename sendemail mail
 to=("recepient@mail.com")
 from=("sender@mail.com")
 subject="I suck at SAS"
 type="text/html"
 attach=("/required/email/signature/logo/logo.png" inlined='pic');

/* If ODS statement placed here; no data _null_ verbiage in body of email */
ods html3 body sendemail rs=none style=sasweb;

data _null_;
 put '<html><body>';
 put 'All,<br> Below are the requested metrics for'"&date"':'<br>;
 put 'Regards,<br>';
 put '<font size="18" face="mistral">GI Jeff<br>';
 put '<img src=cid:pic>';                     
 put '</body></html>';
run;

/* if ODS statement placed here; two separate e-mails containing data _null_ and proc print */
ods html3 body sendemail rs=none style=sasweb;

proc print data=test_data;
 where date=&date;
 title "Metrics for &date";
run;

ods html close;
4 REPLIES 4
G_I_Jeff
Obsidian | Level 7

Kurt,

 

Thanks, that got me half way. Put by putting file print; in the data _null_ step, it does not render the html then. I see all the tags in the body of the e-mail. And thanks for the tip of the <html> & <body> tags. I assumed that but I'm just fooling around at this point and coded them in.

 

Jeff

Kurt_Bremser
Super User

Another method to put text into ODS output is the ods text statement. I've never fiddled around with manually writing tags to an email, though.

Such things I do when writing output to a file:

%let outfile=/path/destination.html;

ods html file="&outfile" (no_bottom_matter);
ods html close;

filename out "&outfile" mod;

data _null_;
file out;
/* put html tagged text here */
run;

ods html file=out (no_top_matter);

/* further ods output */

ods html close;

You could now write the resulting file to the email without using ods.

data _null_;
infile "&outfile";
file email;
input;
put _infile_;
run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1170 views
  • 0 likes
  • 2 in conversation