01-17-2014 12:02 PM
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?
01-17-2014 01:50 PM
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=("firstname.lastname@example.org")
Subject = "An email from SAS"
Attach = "C:\Documents and Settings\chart.gif";
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.
01-20-2014 08:50 AM
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: