Help using Base SAS procedures

is there a way to include standard text in a generated email message?

Reply
N/A
Posts: 0

is there a way to include standard text in a generated email message?

Hello

I work in IT and we use SAS to generate emails and send out data to the business. Currently, each email message is custom but does have similar closing lines. Like "Data is for internal use only.", "Contact IT for assistance", etc.

Is there a way to include standard text at the bottom of each email message? but have this information live in one place instead of being included in each job?

example
put @1 'Here is a report I have created to';
put @1 'give you an overview of the due dates';
put @1 'associated with open tool work orders';
put @1 '-';
put @1 'This E-Mail and report is being generated and mailed';
put @1 'to you automatically using SAS on the mainframe computer.';
put @1 ' ';
put @1 'It will automatically be mailed to you each Friday';
put @1 ' ';
put @1 'If you do not wish to receive this report please';
put @1 'notify me.
run;

Thank you. Also, if this is simply not possible, please let me know. I am new to SAS and have inherited this code to maintain and support.
Frequent Contributor
Frequent Contributor
Posts: 76

Re: is there a way to include standard text in a generated email message?

The simplest thought that I have would be to use SAS Macro language to generate different macros for each kind of message you may want to use. These definitions can be maintained in a single file and then %included with your code that generates the email.

Here is a very simple example. I would recommend looking at SAS Macro language documentation for further explanation.

In file #1, I would do something like this. (Assume filename is messages.sas)

%LET MSG1 = Contact IT for assistance;
%LET MSG2 = Data is for internal use only;


In your source code, I would do this

%include "messages.sas";

Your SAS code example ....

put @1 'Here is a report I have created to';
put @1 'give you an overview of the due dates';
put @1 'associated with open tool work orders';
put @1 '-';
put @1 'This E-Mail and report is being generated and mailed';
put @1 'to you automatically using SAS on the mainframe computer.';
put @1 ' ';
put @1 'It will automatically be mailed to you each Friday';
put @1 ' ';
put @1 'If you do not wish to receive this report please';
put @1 'notify me.' ;
put @1 "&MSG1";
run;
Super Contributor
Super Contributor
Posts: 3,174

Re: is there a way to include standard text in a generated email message?

Macro variable is one approach but then limits change (increase or decrease). Suggest defining a "standard" set of SAS PUT statements in a file and you would use %INCLUDE to have those PUT statements added to any SAS-generated EMAIL as required. No macro code used and having standalone PUT statements simplifies testing and maintenance/change.

However, a more comprehensive approach would be to define a SAS macro which is more robust feature-wise, permitting one to invoke it with optional/required macro var parameters, causing different behavior - simple example below:

%macro emailinfo(rpt=);
%if %length(&rpt) = 0 %then %do;
%* code for global-default invocation. ;
%end;
%else %do;
%if &rpt = aaa %then %do;
%* code for report AAAA invocation. ;
%end;
%else %do;
%* code for all-other report invocation. ;
%end;
%end;
%mend emailinfo;

* add code below where needed to generate SAS code PUT (or other) ;
* statements for customized EMAIL generation. ;
%emailto;


Scott Barry
SBBWorks, Inc.
N/A
Posts: 0

Re: is there a way to include standard text in a generated email message?

thank you for the suggestions and quick reply. it is greatly appreciated!
Ask a Question
Discussion stats
  • 3 replies
  • 85 views
  • 0 likes
  • 3 in conversation