SAS 9.4 allows you to create html5 output with your graph inline (as part of the html), providing a great way to email your SAS/Graph output!
Previously, if you used ods html and dev=png to create graphs, you had to deal with two files -- a png file (containing the graph) and an html file (containing the hotspots, hover-text, and drill down URLs ... or what I like to call "the interactive bits"). And if you wanted to email a graph to someone, you had to attach both files, and then the recipient had to save the two files into a folder, and view the html file (which would then display the png file, with the interactive bits).
In SAS 9.4, you can use ods html5, in combination with the 'inline' option, so that instead of two files, everything is all in one single html file -- even the png graph is cleverly encoded as part of the html file! Here's the basic syntax I use:
Click here to see an example of a single-file SAS 9.4 ods html5 graph. If you're a techno-geek-code-rat, feel free to view the html source to see how the png image is encoded (look for the html 'img' tag).
Now that everything is in a single file, it is very easy to send as an email, and also easy for the recipient to view - all the user has to do is double-click the html attachment in their email!
Here is some SAS code you can use to mail such an html file (I borrowed this technique from Theresa McVie's SESUG paper)
Can you think of any uses for this new functionality in your company?!? Maybe mailing a daily SAS/Graph dashboard? Feel free to post some ideas in the comments!
19 Comments
i want to send the interactive chart, not the static charts, how to do that?
This technique (using ods html5) with SAS/Graph is one way to do that! (where the interactivity is HTML mouse-over text and drill-downs).
Excellent. I use this code all the time. I want send embed image into mail, Does anyone know how I can do it?
Did anyone figure out how to print chart in the body of the email? (I am using SAS 9.3)
Hey All,
I have got the same error as Greg above..."ERROR: An attachment record was truncated. The attachment LRECL is too small." error...
By chance I found out that ct="application/html" works for attaching the html..
for eg. Attach = ("E:\mail_a_graph.html" ct="application/html") lrecl=9999;
I hope it helps...
Thanks for the tip!
I'm using SAS 9.4 to generate a HTML5 file, works just fine, but when attaching the file to an email, I get the "ERROR: An attachment record was truncated. The attachment LRECL is too small." error. I use to get this in 9.2 and it was fixed by adding the (content_type="text/HTML") from this support paper: http://support.sas.com/kb/39/996.html
But for HTML5, it doesn't seem to work, nor does setting LRECL=9999, as other workarounds have suggested. Any thoughts?
Hmm ... I haven't experienced this error. Probably your best bet is to contact SAS Tech support.
There might also be some info in this SAS Communities thread: https://communities.sas.com/message/242906#242906
Using SAS 9.3 - trying to printout gchart in an email and its not working, if you have suggestions please let me know -
x 'cd /users/work222/nbkx65g' ;
/****email starts here*****/
filename outbox email
to=('leonard.wilkerson@bankofamerica.com')
type='text/html'
subject='test';
ods html
body=outbox
rs=none;
PROC PRINT DATA= WORK.pas9168 noobs;
TITLE "PROMOTION_ID:10042825 FOR ACCTS OPEN LESS THAN TODAY RUNNING AS &SYSDATE.";
RUN;
goption reset=all;
axis1 label=none;
axis2 label=('TOTAL POINTS');
title1 'PROMOTION_ID:10042825';
proc gchart data=WORK.pas20616;
vbar group_code / maxis=axis1 raxis=axis2
sumvar=points_earned;
run;
quit;
ods html close;
I'm not too familiar with sending SAS/Graph output in email prior to 9.4 - this would be a good question to run by SAS Tech Support! :)
Did you figure this out?
Any luck with this?
Pingback: Top 4 reasons to upgrade to SAS 9.4 | The SAS Training Post
Pingback: Easy way to send drilldown graphs in an email | SAS Training Post
BTW, I can't get the link to the html5 graph to work. Assume IE8 (sigh) doesn't speak html5. Perhaps I won't be stuck in IE8 forever... : )
I'm not sure which browsers do/don't support this html5 functionality.
I'm using IE 9 and Google Chrome 30.0.1599.101m, and it works in both of them :)
Agree, I will definitely use that as leverage for pushing for the upgrade.
I assume this method could also send a graph in the body of the email (rather than attachment), for those of us who are still allowed to send/receive html emails.
I had tried to do that last year, but settled for sending a PROC REPORT table with links to the graphs (actually to the stored processes that make a graph).
Sending graphs in body of email would be great. Especially given drill-down functionality already there.
Thanks!
Very cool! It has been very hard to explain to people they have to look at both pieces... Now, if I can just get 9.4 installed...
Hopefully useful new features like this will help you justify getting that upgrade completed! :)