BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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.
3 REPLIES 3
LAP
Quartz | Level 8 LAP
Quartz | Level 8
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;
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
deleted_user
Not applicable
thank you for the suggestions and quick reply. it is greatly appreciated!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 593 views
  • 0 likes
  • 3 in conversation