BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
8 REPLIES 8
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
deleted_user
Not applicable
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).
deleted_user
Not applicable
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
deleted_user
Not applicable
I, too, missed out the TYPE parameter mentioned above. Try

FILENAME DOEMAIL . . . TYPE="TEXT/HTML" ;
deleted_user
Not applicable
This still only displays as text.....
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
deleted_user
Not applicable
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
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 970 views
  • 0 likes
  • 2 in conversation