Data visualization with SAS programming

send a barchart in email

Reply
Occasional Contributor
Posts: 16

send a barchart in email

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? 

Trusted Advisor
Posts: 1,137

Re: send a barchart in email

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=("xxxx@xxxxxx.com")

to=("xxxxx@xxxxx.com")

Subject = "An email from SAS"

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

data _null_;

file myemail;

put "Please see attached.";

run;

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.

Thanks,

Jag

Thanks,
Jag
SAS Employee
Posts: 980

Re: send a barchart in email

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:

http://robslink.com/SAS/democd38/iPhone_mailer.sas

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:

http://blogs.sas.com/content/sastraining/2013/11/06/sas-9-4-has-a-new-way-to-send-interactive-graphs...

Ask a Question
Discussion stats
  • 2 replies
  • 937 views
  • 0 likes
  • 3 in conversation