Prior to the second maintenance release of SAS® 9.4 (TS1M2), it is not possible to send an email using SAS where graphics output is embedded in the body of the email. However, beginning with SAS 9.4 TS1M2, this is now possible. The following blog post documents how to do this beginning with SAS 9.4 TS1M2:
Use SAS to send an email that embeds a graph in the body of the email
However, prior to SAS 9.4 TS1M2, when emailing SAS/GRAPH® output, the graph output can be sent only as an attachment to the email and not embedded in the body of the email.
The sample code below demonstrates how to write a PNG graph file to disk and then to send the resulting graph as an attachment to an email:
ods _all_ close;
ods listing;
filename grafout 'c:\temp\sastest.png';
goptions reset=all device=png gsfname=grafout gsfmode=replace;
axis1 minor=none;
proc gchart data=sashelp.class;
where sex="F";
vbar age / sumvar=weight type=mean subgroup=age
nolegend discrete width=10 space=3
raxis=axis1;
run;
quit;
filename grafout clear;
filename sendmail email "first.last@company.com"
subject = "Test sending SAS/GRAPH output via email"
attach = "c:\temp\sastest.png";
data _null_;
file sendmail;
put "Here is the graph you requested";
run;
filename sendmail clear;
If you create multiple graphs that you want to send via email, the recommendation is to write these multiple graphs to a single RTF or PDF document. You can then send the RTF or PDF document as an attachment to your email.
Note that in order to send graphics output as an attachment to an email, you first need to set the EMAILSYS SAS system option to SMTP and the EMAILHOST SAS system option to the name of the SMTP email server for your site.