I’m responsible for a SAS program that runs nightly in batch on a Linux server here at SAS. I am also a road warrior, and routine status checking via a remote connection is often tricky, and sometimes impossible due to unstable hotel internet connections. So I thought “Why can’t SAS just email me a report of how things went? After all, can’t SAS do most anything?” With my DEV environment along for the ride on my trusty laptop, I popped the top and set about teaching my SAS-code minions to report in.
My first stop was the SAS Online Docs for a review of the FILENAME Statement, EMAIL (SMTP) Access Method topic. Encouraged by the presence of sample code (I love sample code!) I performed my first experiment. It looked something like this:
filename mymail email "SASJedi@example.com" subject="Testing-Windows defaults " lrecl=256; data _null_; file mymail; put 'Emailing from SAS is fun!'; put 'Stay SASy!'; put 'Mark'; run;
And up popped my first surprise: Windows detected that SAS was trying to send email and – I’m sure as part of an effort to prevent SPAM sent on my behalf by malware – insisted that I click a button before the email would be sent. I understood that this would NOT be the default behavior on Linux, but decided to investigate anyway. It all boiled down to setting the proper EMAIL options in SAS. I recorded this video tip (about 6 minutes long) documenting my progress as I use the Force (well, the SAS OPTIOINS, anyway) to control the way SAS sends email.
The SAS code used in the video is included at the bottom of this post (because I'm betting you love sample code as much as I do!)
Now that I’ve got SAS sending email as expected using SMTP, in my next blog entry I’ll tackle creating “pretty” email (using HTML) and sending out emails with attachments.
Until next time, may the SAS be with you.
Mark
Emailing from SAS ZIP file
6 Comments
I see great minds think alike :)
http://support.sas.com/resources/papers/proceedings11/005-2011.pdf
Nice! I really liked the detailed, step-by-step instructions you've put together for scheduling SAS jobs to run unattended on Windows.
I use a similar approach to have SAS send me text messages as various stages of long-running jobs are completed. (With my particular smart-phone and its settings, text messages are more instantaneous than having to manually poll for new emails periodically...especially afterhours when I'm away from my desk.) Instead of having SAS send a message to my standard work email or personal email, I use the SMS gateway address that sends email as a text message to my phone -- "3035551212@pm.sprint.com". Most carriers have SMS gateways for text-via-email -- http://en.wikipedia.org/wiki/List_of_SMS_gateways
This is a very nice tip! Thanks for posting it here :-)
This is wonderful, but how can one do this if one's system uses exchange instead of SMTP to send email?
Or download a program called "Clickyes" and install.