BookmarkSubscribeRSS Feed
Calcite | Level 5

hi, I am wondering how to send a bar chart in email, it could be in the body or text. the SAS job is scheduled to run a SAS server. I tried to save the chart as gif on the server first, then send it as an attachment, however, the .gif is not saved in the directory as specified in the program, it is saved at some random work folder. So when attaching to the email, the email failed because not being able to find the attachement. Any ideas? 

Amethyst | Level 16

is it possible for you to write another code in the same program where you can direct the output to a desired location. probably you can give a specific path, so that the generated chart be saved. After this code you can write the following code, which will send the chart as attachment to the email address mentioned

filename myemail email from=("")


Subject = "An email from SAS"

Attach = "C:\Documents and Settings\chart.gif";

data _null_;

file myemail;

put "Please see attached.";


During execution of the sas code, first the chart will be generated and will be saved in the desired location and then email code will execute which will send the attachment.



Meteorite | Level 14

Jagadishkatam is definitely pointing you in the right direction!

To give a more complete answer, it would be useful to see your SAS code. The code to control where the output is written will vary, depending on a lot of things.

Also, how you're scheduling the job to run on a SAS server (via EG, a stored process, a Unix cron job, a Windows scheduled task, etc) ... and are you using the SAS job to send the email & attachment, or is that a Unix/DOS script, etc? I would suggest doing it all in the SAS job, as Jagadishkatam has shown. Here is a SAS job similar to his, that shows how to include multi-line text in the email:

And, if you've got SAS 9.4, there's even a new/enhanced way to send graphs! You can use html5 to create a single html file that contains both the graph and the html overlay (with html mouse-over text, drilldowns, etc). Assuming you've got SAS 9.4, and your email recipients are using a browser that supports html5. Here's a blog post with more details:


Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.


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
  • 2 replies
  • 3 in conversation