Presentation is loading. Please wait.

Presentation is loading. Please wait.

Emailing with SAS – Jerry Le Breton, Softscape Solutions SAUSAG 40 – 19 May 2005 Emailing with SAS How and why to send emails from SAS programs Jerry Le.

Similar presentations


Presentation on theme: "Emailing with SAS – Jerry Le Breton, Softscape Solutions SAUSAG 40 – 19 May 2005 Emailing with SAS How and why to send emails from SAS programs Jerry Le."— Presentation transcript:

1 Emailing with SAS – Jerry Le Breton, Softscape Solutions SAUSAG 40 – 19 May 2005 Emailing with SAS How and why to send emails from SAS programs Jerry Le Breton - Softscape Solutions

2 Emailing with SAS – Jerry Le Breton, Softscape Solutions SAUSAG 40 – 19 May 2005 Why use SAS to send emails?  Simple automation for distributing reports  Programmatic / conditional emails  Customised emails

3 Emailing with SAS – Jerry Le Breton, Softscape Solutions SAUSAG 40 – 19 May 2005 FILENAME Statement is the Key  filename mail email “jerry@softscape.net.au" subject="Party Invite"; attach="c:\pictures\wildparty3.jpg"; data _null_; file mail; put "Hi Jerry,"; put "The IT department is holding another of its wild parties on Friday."; put "It was the talk of the town last year. Pity you couldn't make it."; put "Attached is a picture from last time - so you can prepare yourself!"; put "Cheers, Doug"; run; Special EMAIL device type Various options for sending emails

4 Emailing with SAS – Jerry Le Breton, Softscape Solutions SAUSAG 40 – 19 May 2005 Controlling Emails in the Data Step filename mail email "jerry@softscape.net.au" subject="Party Invite" attach="c:\pictures\wildparty3.jpg"; data _null_; file mail to=(“sandy@softscape.net.au" "alan@softscape.net.au") cc="jerry@softscape.net.au" subject="Wilder Party Invite" attach="c:\pictures\wildparty4.jpg"; put "Hi Sandy and Alan,"; put "Sorry - of course you're invited too."; put "Attached is an even better picture from last time."; put "Make sure the kids aren’t looking over your shoulder!"; put "Cheers, Doug"; run; FILE statement options override those on the FILENAME statement

5 Emailing with SAS – Jerry Le Breton, Softscape Solutions SAUSAG 40 – 19 May 2005 Customising Emails from the Data Step  Special email “directives” enable filename options to be overridden / changed, for each Data step iteration. filename mailout email "nul" ; data _null_; set emaillist end=theend; retain subject 'Remember: The Wild Party is Tonight'; file mailout ; put '!EM_TO!' emailid; /* The TO address is on the input data set */ put '!EM_SUBJECT!' subject; /* Overrides FILE and FILNAME specification */ put 'Hi ' firstName ; /* Insert first name into first line */ /* Put the main body of the email... */ put / "Remember the IT Department's Wild Party starts at 7.00pm tonight." // "Be warned - it'll go late (at least 9.00)." // "Doug"; put '!EM_SEND!'; /* Send the email now */ put '!EM_NEWMSG!'; /* Clear current email attributes */ if theend then put '!EM_ABORT!'; /* Stops auto send at end of Data step */ run;

6 Emailing with SAS – Jerry Le Breton, Softscape Solutions SAUSAG 40 – 19 May 2005 Emailing ODS Output  To email ODS output… … it’s trivial.

7 Emailing with SAS – Jerry Le Breton, Softscape Solutions SAUSAG 40 – 19 May 2005  Send HTML output directly to an email:  /* Sample program sending Proc output to an email address */ filename outfile email subject= "Sales Summary" from = "jerry.lebreton@afp.gov.au" to = "jerry@softscape.net.au" type = "text/html"; ods html body=outfile; title j=left " Total Sales by Country and Product"; proc tabulate data =sashelp.prdsale f=dollar10. missing style=[background=beige]; class prodtype / style=[foreground=blue]; class country / style=[foreground=green]; var actual ; table country all*[style= [background=white font_weight=bold]], prodtype*actual=''; keylabel sum=' '; keyword all / style=[font_weight=light font_style=italic foreground=red]; run; ods html close; Emailing ODS Output The FILENAME statement does it all. Note the TYPE option for sending html. For all emails these options need setting in the config file : -emailsys smtp -emailhost your.smtp_server.host

8 Emailing with SAS – Jerry Le Breton, Softscape Solutions SAUSAG 40 – 19 May 2005 SAS and other emailers  Can use other email programs e.g. smtpsend utility (no client e.g. Outlook) data _null_; call system("smtpsend -hsmtp.softscape.net.au -f&fromid -t&toid -sFooty Update Log -ic:\footy\error_report.txt -ac:\footy\weekend_update.log"); run; h ost f rom t o s ubject i nclude(d text) a ttachment

9 Emailing with SAS – Jerry Le Breton, Softscape Solutions SAUSAG 40 – 19 May 2005 So…  Emailing from SAS is one more way to Automate distribution of reports Customise results Target output.  References: V8 OnlineDoc: Base SAS Software / Host Specific Information / Windows Environment / Using Groupware to Distribute SAS Data / Sending Electronic Mail Automated distribution of SAS results – Jacques Page www2.sas.com/proceedings/sugi29/039-29.pdf

10 Emailing with SAS – Jerry Le Breton, Softscape Solutions SAUSAG 40 – 19 May 2005 Questions? Jerry Le Breton 0414 513 270 Jerry@SoftscapeSolutions.com.au www.SoftscapeSolutions.com.au

11 Emailing with SAS – Jerry Le Breton, Softscape Solutions SAUSAG 40 – 19 May 2005 Custom Emails from the Data Step  Special email “directives” enable filename options to be overridden, for each Data step iteration. filename mailout email "nul" from='Jerry@Softscape.net.au'; data _null_; set emaillist end=theend; retain subject 'Remember SAUSAG today'; file mailout subject="Subject line" ; put '!EM_TO!' emailid; /* The TO address is on the input data set */ put '!EM_SUBJECT!' subject; /* Overrides FILE and FILNAME specification */ put 'Hi ' firstName ; /* Insert first name into first line */ /* Put the main body of the email... */ put / "Remember SAUSAG starts at 4.00pm today." // "See you there." // "Jerry"; put '!EM_SEND!'; put '!EM_NEWMSG!'; if theend then put '!EM_ABORT!'; run;


Download ppt "Emailing with SAS – Jerry Le Breton, Softscape Solutions SAUSAG 40 – 19 May 2005 Emailing with SAS How and why to send emails from SAS programs Jerry Le."

Similar presentations


Ads by Google