Hi Guys, hope you can help with this one:
I'm generating a SAS mail, which is supposed to distribute a mail with exchange rate fluctuations to a group of receivers. However, the procedure does not "print" the data table to the mail. Somehow, the procedure genereates the mail destributes it only with a text, and afterworth creates the table, that was supposed the be part of the mail.
Can anyone help me with this?
My code can be seen below:
FILENAME outbox EMAIL "xxx@xxx.xx";
DATA _NULL_;
FILE outbox
/* Overrides value in filename statement */
to=("xxx@xxx.xx")
cc=("")
subject="return %SYSFUNC(putn(&ReportDate,DDMMYY10.)) and daily prices %SYSFUNC(putn(&LastDate_FT,DDMMYY10.))";
ods listing CLOSE;
ods html3 style=sasweb;
options center;
put "Daily market prices and returns";
TITLE1 "excehange rate fluctuations %SYSFUNC(putn(&LastDate_FT, DDMMYY10.))";
FOOTNOTE;
run;
proc report data=WORK.DELTAREPORTNAMES nowd;
column ReportName Delta cv1;
define ReportName / group " " format=$20. missing order=formatted;
compute ReportName;
if ReportName ne " " then hold1=ReportName;
if ReportName eq " " then ReportName=hold1;
endcomp;
define Delta / group missing noprint;
define cv1 / computed "delta(%)" missing FORMAT=COMMAX20.2;
compute cv1;
if Delta ne . then hold2=Delta;
cv1=hold2;
endcomp;
quit;
ODS HTML CLOSE;
ods listing;
RUN;
Best, Joe.
Here's the code I use and it works perfectly fine in Outlook:
ods _all_ close;
filename mymail email from="YOUREMAIL@SOMEWHERE.COM"
cc="CC_IF_REQUIRED@SOMEWHERE.COM"
subject="Your E-mails Title"
content_type="text/html";
ods msoffice2k file=mymail
style = sasweb ;
*proc report code below...;
proc report data = .....
run ;
ods msoffice2k close;
If you want to e-mail the report created by PROC REPORT you will need to create it in a file and attach the file to the e-mail.
So there is no way to get a table in a mail generated from SAS 9.3? Of course I can generate the table in a seperate step and attach it, but for layout-purposes I would really appreciate if the table could be a part of the mail.
What if I generated the table by PROC SQL instead?
The file(s) created by ODS HTML.
As you currently have it the DATA _NULL_ step sends an email when it executes, and that happens before the table is produced by your PROC REPORT step.
What you want is the table in the body of the email, correct?
One way you can do this is to run the PROC REPORT step first, and write the results to an html file.
Then in your data step which sends the email, read that file. Soemthing like (untested):
data _null_; file outbox ; infile MyHTMLoutput ; *may need to set lrecl; input ; put _infile_ ; run;
Above assumes to= subject= etc are all defined in the filename statement for outbox.
I have done that before when I wanted to add text to the message. But if you want to send just the html produced by ODS, would think you could do it with something like:
ods html3 style=sasweb file=outbox;
*PROC REPORT here;
ods html3 close;
HTH,
--Q.
Well, the code works great now, and in SAS it generates the HTML output as I expect. However, in Outlook the HTML output is only in plain text/HTML code, and not the table from SAS. Do any of you have an idea about, what is wrong? I do not seem to be able to find an explanation or a solution anywhere... :smileyplain:..
JoeBill wrote:
Well, the code works great now,..
what code?
The code Quentin offered. However, outlook only displays the plain HTML code. Any clue of why that is?
This first example is from the SAS online help for the FILENAME EMAIL statement. It sends me an HTML formatted report in the email text.
Does including the following e-mail option help?
ct="text/html"
Hi,
I had a g8t time in exploring option of sending mail from SAS. See I wanted to send mail which had content in body and table attached to it. I first tried sending from data null then sending table content did not work. When I moved to using proc report. all i was able to do was send table but I was not able to write content first then send have table.
So I tried different approach:
I first created table and stored content in macro variable. and then under data null use html to send content...
Here's the code I use and it works perfectly fine in Outlook:
ods _all_ close;
filename mymail email from="YOUREMAIL@SOMEWHERE.COM"
cc="CC_IF_REQUIRED@SOMEWHERE.COM"
subject="Your E-mails Title"
content_type="text/html";
ods msoffice2k file=mymail
style = sasweb ;
*proc report code below...;
proc report data = .....
run ;
ods msoffice2k close;
Thanks guys!
Great help! It works perfectly fine now, and the HTML output is looking great in the mail!
Thanks again!
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: