SAS 9.4 has a new way to send interactive graphs in email!

16

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!

 

Share

About Author

Robert Allison

The Graph Guy!

Robert has worked at SAS for over 20 years, and is perhaps the foremost expert in creating custom graphs using SAS/GRAPH. His educational background is in Computer Science, and he holds a BS, MS, and PhD from NC State University. He is the author of several conference papers, has won a few graphic competitions, and has written a book (SAS/GRAPH: Beyond the Basics).

16 Comments

  1. 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...

  2. 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!

  3. 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... : )

    • Robert Allison
      Robert Allison on

      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 :)

  4. Pingback: Easy way to send drilldown graphs in an email | SAS Training Post

  5. Pingback: Top 4 reasons to upgrade to SAS 9.4 | The SAS Training Post

  6. leonard wilkerson on

    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;

  7. 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?

  8. 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...

Leave A Reply

Back to Top