FIRST STEP - ADDITIONS TO THE CONFIGURATIONS FILE (CONFIG FILE) SECOND STEP Creating the email to send

Similar documents
SENDING S IN SAS TO FACILITATE CLINICAL TRIAL. Frank Fan, Clinovo, Sunnyvale CA

Sending s in SAS to Facilitate Clinical Trial Frank Fan, Clinovo, Sunnyvale, CA

Automated distribution of SAS results Jacques Pagé, Les Services Conseils HARDY, Quebec, Qc

Paper TT09 Using SAS to Send Bulk s With Attachments

An macro: Exploring metadata EG and user credentials in Linux to automate notifications Jason Baucom, Ateb Inc.

Using Macros to Automate SAS Processing Kari Richardson, SAS Institute, Cary, NC Eric Rossland, SAS Institute, Dallas, TX

You have got SASMAIL!

SAS Credit Scoring for Banking 4.3

Automation of Large SAS Processes with and Text Message Notification Seva Kumar, JPMorgan Chase, Seattle, WA

Novar Database Mail Setup Guidelines

NetWrix SQL Server Change Reporter. Quick Start Guide

ArcMail Technology Defender Mail Server Configuration Guide for Microsoft Exchange Server 2003 / 2000

A Comprehensive Automated Data Management System Using SAS Software

PS004 SAS , using Data Sets and Macros: A HUGE timesaver! Donna E. Levy, Dana-Farber Cancer Institute

McAfee Network Threat Response (NTR) 4.0

Secrets of Event Viewer for Active Directory Security Auditing Lepide Software

Outlook 2010 Essentials

Using DDE and SAS/Macro for Automated Excel Report Consolidation and Generation

Mobile Business Applications: Delivering SAS Dashboards To Mobile Devices via MMS

& text message (SMS) relaying using Talk2M

PGP Desktop Quick Start Guide version 9.6

I NTRODUCTION F INDING I NFORMATION

Automating SAS Macros: Run SAS Code when the Data is Available and a Target Date Reached.

Nokia for Business. Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation

Optimizing System Performance by Monitoring UNIX Server with SAS

DLP Quick Start

Importing Excel Files Into SAS Using DDE Curtis A. Smith, Defense Contract Audit Agency, La Mirada, CA

XMailer Reference Guide

Core Essentials. Outlook Module 1. Diocese of St. Petersburg Office of Training

Search and Replace in SAS Data Sets thru GUI

OS/390 SAS/MXG Computer Performance Reports in HTML Format

Vector HelpDesk - Administrator s Guide

SAS ODS HTML + PROC Report = Fantastic Output Girish K. Narayandas, OptumInsight, Eden Prairie, MN

ABSTRACT THE ISSUE AT HAND THE RECIPE FOR BUILDING THE SYSTEM THE TEAM REQUIREMENTS. Paper DM

Dove User Guide Copyright Virgil Trasca

TNote125 Student Locator Framework Notification Diagnostics

Review Guide: Exclaimer Mail Utilities Disclaim, Brand, Sign & Protect

Essential Project Management Reports in Clinical Development Nalin Tikoo, BioMarin Pharmaceutical Inc., Novato, CA

SAP Business Objects Data Services Setup Guide

Using SAS With a SQL Server Database. M. Rita Thissen, Yan Chen Tang, Elizabeth Heath RTI International, RTP, NC

Manual Password Depot Server 8

Issue 2EN. Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation

GFI White Paper: GFI FaxMaker and HIPAA compliance

Configuring a SAS Business Intelligence Client with the SAS Server to Support Multilingual Data Wei Zheng, SAS Institute Inc.

Utilizing SAS for Complete Report Automation Brent D. Westra, Mayo Clinic, Rochester, MN

CipherMail Gateway Quick Setup Guide

Customer Tips. Configuration and Use of the MeterAssistant Option. for the user. Purpose. Xerox Device Configuration. Xerox Multifunction Devices

TU04. Best practices for implementing a BI strategy with SAS Mike Vanderlinden, COMSYS IT Partners, Portage, MI

Interactive Reporting er Manual

Outlook . User Guide IS TRAINING CENTER. 833 Chestnut St, Suite 600. Philadelphia, PA

WaveWare Technologies, Inc. We Deliver Information at the Speed of Light

ABSTRACT INTRODUCTION DATA FEEDS TO THE DASHBOARD

Helpdesk for JIRA

Background Information

Creating Dynamic Web Based Reporting

Here are the steps to configure Outlook Express for use with Salmar's Zimbra server. Select "Tools" and then "Accounts from the pull down menu.

CONFIGURATION AND SETUP USER GUIDE AND REFERENCE MANUAL

Focus On echalk . Introduction. In This Guide. Contents:

Chapter 3 ADDRESS BOOK, CONTACTS, AND DISTRIBUTION LISTS

While You Were Sleeping - Scheduling SAS Jobs to Run Automatically Faron Kincheloe, Baylor University, Waco, TX

CITY OF BURLINGTON PUBLIC SCHOOLS MICROSOFT EXCHANGE 2010 OUTLOOK WEB APP USERS GUIDE

Hands-On Workshops. HW009 Creating Dynamic Web Based Reporting Dana Rafiee, Destiny Corporation, Wethersfield, CT OVERVIEW OF SAS/INTRNET SOFTWARE

IMAGINE... Everything You Expect From CRM Integrated Marketing. And More! marketing campaigns that...

Admin Guide Domain Administration. Version 21

Lotus Notes Client Version 8.5 Reference Guide

EJGH Encryption User Tip Sheet of 8

Secure Client User Guide Receiving Secure from Mercantile Bank

Amy wants to use her to view some photos her friend Sandy sent, from her vacation to Washington DC.

APPLICATION BRIEF ADMINISTRATION J-MAIL

Nokia E90 Communicator support

WebCUR ListServ. ListServ Help Manual

Secure Frequently Asked Questions

Using the PeaceHealth Secure System

OmniTouch 8400 Instant Communications Suite. My Instant Communicator for Microsoft Outlook User guide. Release 6.7

Configuring Notifications for Cisco Unified MeetingPlace Express

Outlook 2010 basics quick reference sheet

This guide consists of the following two chapters and an appendix. Chapter 1 Installing ETERNUSmgr This chapter describes how to install ETERNUSmgr.

SUGI 29 Applications Development

Cloud. Hosted Exchange Administration Manual

Matrix Technical Support Mailer - 72 Procedure for Image Upload through Server in SATATYA DVR,NVR & HVR

Word Secure Messaging User Guide. Version 3.0

Fax Sending Guide

1 Accessing accounts on the Axxess Mail Server

Configuring Notification for Business Glossary

Result: Adds an X-header named "X-Company" with the value of "Your Company Name"

Merak Outlook Connector User Guide

Module One: Getting Started Opening Outlook Setting Up Outlook for the First Time Understanding the Interface...

Documentum Content Distribution Services TM Administration Guide

Outlook And Outlook Web App For. Trent University

NetWrix File Server Change Reporter. Quick Start Guide

Mailwall Remote Features Tour Datasheet

AD Self Password Reset Installation and configuration

Order from Chaos: Using the Power of SAS to Transform Audit Trail Data Yun Mai, Susan Myers, Nanthini Ganapathi, Vorapranee Wickelgren

AlienVault. Unified Security Management (USM) 5.x Policy Management Fundamentals

Rev 7 06-OCT Site Manager Installation Guide

Session Attribution in SAS Web Analytics

Create! Upgrade Notes

Configuring -to-Feed in MangoApps

Bulk Downloader. Call Recording: Bulk Downloader

NETWRIX EVENT LOG MANAGER

Transcription:

Using SAS to E-Mail Reports and Results to Users Stuart Summers, Alliant, Brewster, NY ABSTRACT SAS applications that are repeatedly and periodically run have reports and files that need to go to various end users. SAS is able to use Simple Mail Transfer Protocol (SMTP) to send completion notices and logs, lists and any other reports as attachments. With three lines in the config file you can set up the code in your process to email your results to individuals and/or distribution lists. This paper will provide the lines to add to the config file as well as an example of how to set up your code to send the emails. INTRODUCTION We have all been there. You create, test and release an application using SAS that creates files and various reports and listings for your clients and/or end users and they want to get notifications via email with their reports as attachments in the email. The application is run perhaps monthly, weekly, daily or even at odd hours of the day or night. Instead of having someone monitor when the application completes and sending out the email, SAS is able to use Simple Mail Transfer Protocol (SMTP) to send the email out with whatever reports and information that you want to give your users. This paper will lay out the initial set up and the steps/code that can be included in your application to your job to send the email for you. 1

FIRST STEP - ADDITIONS TO THE CONFIGURATIONS FILE (CONFIG FILE) This step needs the assistance/cooperation of your Systems Administrator. The following in an example of what options are needed in the config file (by your Sys Admin person): -emailhost testhub.nesug.com -emailsys smtp -emailport 24 The first line is the domain name for the SMTP server for your site. The second one is obvious since we are telling SAS to use SMTP to send emails. The last one is the port that SAS needs to connect to in order to send the email. SECOND STEP Creating the email to send Everyone knows the parts of email: Who is supposed to get it ( To:, CC:, BCC: ), Who is sending it ( From ), the heading/subject of the email, any attachments, and the main body which has the text of the email. EXAMPLE CODE /*--------------------------------------------------------------------------*/ /* Use ODS to set up the html reporting that will be attached to the email*/ /*--------------------------------------------------------------------------*/ ods html body = '/home/ssummers/nesug/nesug_install_report.html'; proc means data=nesug.nesug_install n nmiss min max mean; title1 j=left "Alliant "; title2 j=left "Data Licensing Install - Variable Means Report"; title3 j=left "Produced for client: NESUG "; title4 j=left "Metrics report on Consumer Attributes for Client Evaluation (2 percent cross section of total file)"; Footnote1 j=left height=8pt "Confidentiality Note: This report, including any attachments,is intended only for the person or entity to which it is addressed and may"; Footnote2 j=left height=8pt "contain information that is privileged, confidential or otherwise protected from disclosure. Dissemination, distribution or copying of"; Footnote3 j=left height=8pt "the report or the information herein by someone other that the intended recipient, or an employee or agent responsible for delivering"; Footnote4 j=left height=8pt "the report to the intended recipient, is prohibited. If you have received the report in error, please call Alliant, LLC at (845)276-2600"; footnote5 j=left height=8pt "and destroy the original report and all copies."; ods html close; /*------------------------------------------------------------------------------*/ /* Now set up and send the email with the SAS log, SAS list and the HTML report */ /* as attachments */ /*------------------------------------------------------------------------------*/ filename sendmail Email Subject="NESUG Basic Email Example" Attach=("/home/ssummers/nesug/email_example.log" "/home/ssummers/nesug/email_example.lst" "/home/ssummers/nesug/nesug_install_report.html"); data _null_; file sendmail; name='ssummers@alliantdata.com'; sender='production@alliantdata.com'; put '!em_to!' name; put '!em_from!' sender; 2

put '!em_sender!' sender; put 'This is an example of a simple e-mail message with three attachments:';; put 'The SAS log, the SAS list and an HTML report';; put /'A two percent cross_section of consumer attributes from the Alliant Database is available for evaluation as an install file.';; put /'Attached is a metrics report on some of these attributes'; put //; put '!em_send!' ; put '!em_abort!'; BREAKING (DOWN) THE CODE It s pretty much straight forward code. The FILENAME statement will let the system know we are setting up an email and what goes in the subject line. I ll get to attachments soon. The rest is just writing code to write records to the file you just set up. Keywords to be aware of (And yes, all of these keywords are supposed to be bracketed by exclamation points):!em_to! identifies would is supposed get the email (the To: line)!em_from! and!em_sender! identifies who it is from (the From: line) and who the sender is. If they are not same then the emails with put Sender ON BEHALF OF From in the From: line. The PUT statements after this contains the text body of the email. With the text lines use two semi colons at the end to start the next text line on the line (single spaced). If you don t, the next line will be tacked on to the end of the one above it. Use / to insert a blank line above the text ( // will put two blanks above if you need to).!em_send! Everything is in place, so send the email;!em_abort! This is what I call a safety valve in that it prevents a second copy of the email to go out after the DATA step is finished. 3

EMAIL PROCESS AS A MACRO If you a process that runs on a regular (or sometimes irregular) schedule consider adding the email as a macro. It is also a possible approach if the emails differ only by report names. The basic logic is similar to the prior code example. %macro nesug_email(client=nesug, qcreport=, client_file=, email_list=ssummers ); /*--------------------------------------------------------*/ /* Macro: /a21/sas/macros/nesug_email.sas */ /* Author: Stuart Summers Date: 07/25/2012 */ /* Function: Macro example of using SAS to email files */ *--------------------------------------------------------*/ /* Macro Parameters: */ /* client - Name and/or abbreviation of client */ /* qcreport - directory and file name of audit report */ /* client_file - directory and file name for file to */ /* return to client */ /* email_list - recipient list for email alert */ /*--------------------------------------------------------*/ %put Set up email list ; %put ; data _null_ ; call execute("data email_list; "); call execute("length temp_name $ 32; "); call execute("input temp_name $ @@; "); call execute("cards; "); call execute("&email_list "); call execute("; "); call execute(" "); /* Send print of email recipent list to */ /* SAS listing for manual confirmation */ proc print data=email_list; %put Send out alerts ; %put ; /* Set up subject and attachments */ /* for email file */ filename sendmail Email Subject="Data Contribution - ETL Transaction Completion: %trim(&client)" Attach=("%cmpres(&qcreport)" );; /* Build out recipient email address */ /* for email em_to */ /* set up from and sender addresses */ data _null_; set email_list end=lastobs; name=quote(trim(cats(temp_name,"@alliantdata.com"))); 4

file sendmail; put '!em_to!' name; sender=quote(trim("production@alliantdata.com")); put '!em_from!' sender; put '!em_sender!' sender; /* Only need to create email message */ /* once so only create it on the */ /* first obs */ IF _N_=1 THEN DO; put 'This is an example of a simple e-mail message'; put 'generated and issued using SAS'; put /; put 'Skipping two lines by add /'; put //; /* add the em_send for each recipient email */ /* for email em_to */ /* set up from and sender addresses */ put '!em_send!'; if lastobs=0 then return; /* loop back to get next recipient */ else put '!em_abort!'; /* send abort flag (only send once)*/ %exit: %mend nesug_email; CONCLUSION Automating the distribution of reports for processes that run on a regular basis is an obvious time saver. SAS provides a fairly easy process tool for that purpose. REFERENCES: SAS 9.1 Language Reference: Dictionary. Cary, NC: SAS Institute Inc. ACKNOWLEDGMENTS SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. indicates USA registration. CONTACT INFORMATION Your comments and questions are valued and encouraged. Contact the author at: Stuart Summers Senior Data Analyst Alliant 301 Fields Lane Brewster, NY 10509 Work Phone: 845-276-2600 ext. 242 Fax: 845-276-2605 Email: ssummers@alliantdata.com Web: www.alliantdata.com * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 5