BookmarkSubscribeRSS Feed
YW_CA
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? 

2 REPLIES 2
Jagadishkatam
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=("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
GraphGuy
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:

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

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1863 views
  • 0 likes
  • 3 in conversation