The SAS Output Delivery System and reporting techniques

Emailing via ODS

Reply
N/A
Posts: 0

Emailing via ODS

Hi,

is there a way of emailing a small dataset via the ODS,
i did find a bit of script to do it but this caused a thousand and one errors and when i finally got it to email something, it was all text and no formatting. So i gave up on that, and resorted to sending it as an attachment:

filename doemail email
to= 'to@me.com'
from='from@me.com'
subject="&emailsubject."
attach="C:\stuff\DailyTop5_&wordsday..xls";

data _null_;
file doemail;
put 'Hi All,';
put;
put "Please find attached the daily top5 figures for &wordsday.";
put;
put 'Thanks';
run;

This is fine but was a quick fix, now i have some time i would like it to be in the body of the email like:
"
Hi All

here are the Daily Top 5 Figures for 06NOV2008

Position Name Figure
1 Rod 150
2 Jane 120
3 Freddy 119
4 Zippy 100
5 George 62

Thanks
"
obviously i would like the table to be an actual table.

any ideas?

thanks
Super Contributor
Super Contributor
Posts: 3,174

Re: Emailing via ODS

Posted in reply to deleted_user
Review the use of TYPE= parameter on your FILENAME when sending "formatted" output imbedded in your EMAIL body. There are examples on the SAS support website.


Scott Barry
SBBWorks, Inc.
N/A
Posts: 0

Re: Emailing via ODS

Posted in reply to deleted_user
If your observations are in a SAS dataset, you can PROC PRINT them as follows:

ODS HTML FILE=DOEMAIL;

PROC PRINT DATA=RESULTS;
VAR NAME VALUE;
RUN;

ODS HTML CLOSE;

The above works because HTML is a valid format for emails.

Because I run my work on the z/OS platform, my opening ODS HTML statement also has the RS=NONE STYLE=MINIMAL options.

You may be able to use TITLE and FOOTNOTE statements to get other text on the page. If not, you may need DATA steps as in your example before and after PROC PRINT (between the ODS HTML pair).
N/A
Posts: 0

Re: Emailing via ODS

Posted in reply to deleted_user
Hi I have tried this and it doesnt display as html it is text.
i have checked my outlook to display as html.
If i copy what is emailed to me and open it in a html viewer it looks like the way i want it
this is very strange, any help will be much appreciated? Also could this be to do with every time i run this script outlook comes up with the warning prompt, saying allow or deny?

Message was edited by: Spud
N/A
Posts: 0

Re: Emailing via ODS

Posted in reply to deleted_user
I, too, missed out the TYPE parameter mentioned above. Try

FILENAME DOEMAIL . . . TYPE="TEXT/HTML" ;
N/A
Posts: 0

Re: Emailing via ODS

Posted in reply to deleted_user
This still only displays as text.....
Super Contributor
Super Contributor
Posts: 3,174

Re: Emailing via ODS

Posted in reply to deleted_user
So, just to be clear as mud, you are seeing SAS-generated HTML code in your EMAIL. So that means your EMAIL client is not detecting the EMAIL as being HTML-formatted. This condition only occurs for me when I forget to code the TEXT= parameter. So, please share (in a post to the list) the exact FILENAME and ODS HTML statement you are executing for feedback.

Scott Barry
SBBWorks, Inc.
N/A
Posts: 0

Re: Emailing via ODS

Morning

filename doemail email
to= 'to@me.com'
from='from@mecom'
subject="&emailsubject."
attach="c:\myfile.xls"
TYPE="TEXT/HTML";

ODS HTML FILE=DOEMAIL;

PROC PRINT DATA=myfile;
RUN;

ODS HTML CLOSE;

Thanks
Simon
Super Contributor
Super Contributor
Posts: 3,174

Re: Emailing via ODS

Posted in reply to deleted_user
I use a similar coding technique as you have shared, except the ODS parameter parameter is coded to prevent HTML tag truncation.

So, again, the question: are you seeing HTML code in the EMAIL you receive or a text reporting listing? Also, has the code (or something similar) ever worked previously where you send SAS-generated HTML reports via EMAIL?

And, mention again, the sending and receiving operating system environments, EMAIL client? Also, your SAS version and service pack / HOTFIX maintenance levels are something to consider.

Also, consider an attempt without the ATTACH= parameter to determine any different SAS behavior with your EMAIL content.

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 8 replies
  • 277 views
  • 0 likes
  • 2 in conversation