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.
Emailing from SAS ZIP file