BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

Hello

The following code send an email via sas with attached XLSX file and some sentences in email body.

I want to add also to the body of email a summary report

with following code:

 

proc report data=Last_7Days_c nowd;
compute 'סטטיסטי'n;
if substr(STAT,1,4)='AMNT then
call define(_row_, "style", "style=[backgroundcolor=lightyellow]");
endcomp;
run;

Here is the code that run 100% but I need to add the summary report to body of email.

What is the way to do it?

Can you show the code please?


filename outbox EMAIL;
data _null_;
FILE outbox
to=("[email protected]") 
FROM='SAS  <[email protected]>'
subject="Summary Sales"
encoding='utf-8' 
attach=("/path/My_File.xlsx"
content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
file outbox;
ODS LISTING CLOSE;
ODS HTML BODY=mail;
put "Hello ";
put "Please see attached a file with summary report";
put "population-Customers age 20-40";
put " ";
put "Regards,";
run;
3 REPLIES 3
Ronein
Onyx | Level 15

Here I write the text in body email in following way:   put " text"

In the other way I write the text in body email in following way: ods html text = " ";

The way put ="" provide much nicer result.

I didnt succeed add summary table to body email when using put ""

 

 

 

Kurt_Bremser
Super User

You have much more options regarding the format of the text when you use ODS TEXT instead of PUT in a DATA step. See the example for the use of PROC TEMPLATE:

options obs=10;
proc template;
   define style Styles.MyStyle;
   parent=styles.htmlblue;
   style usertext from usertext /
      foreground=red;
   end;
run;
ods html file="text.html" style=Styles.MyStyle ;
ods pdf file="text.pdf" startpage=never notoc style=Styles.MyStyle ;
ods rtf file="text_trad.rtf" style=Styles.MyStyle ;
title "January Orders ";
footnote " For All Employees";
ods text="My Text 1";
ods text="My Text 2"; 
proc print data=exprev;
run;
ods text="My Text 3"; 
ods pdf close;
ods rtf close;
ods html close;
title;
footnote;
proc template;
   delete Styles.MyStyle ;
run;

taken from ODS TEXT= Statement 

Run your procedure creating the summary report while the ODS destination to the mail is open.

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

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
  • 3 replies
  • 2382 views
  • 0 likes
  • 2 in conversation