BookmarkSubscribeRSS Feed
franph
Calcite | Level 5

Hi

 

I am using SAS EG / Base SAS &  trying to send emails to different recipients depending on certain criteria,  I have this bock of code within the program.

 

if (&Customer_Segment='R' or 'U') then do;
file sendit email
from = "XXX@company.co.nz"
to = ("YYY@company.co.nz") 
subject= "TEST email 1" ;end;


if (&Customer_Segment='S') then do;
file sendit email
from = "XXX@company.co.nz"
to = ("ZZZ@company.co.nz") 
subject= "TEST email 2" ;end;


if (&Customer_Segment='C' or 'P') then do;
file sendit email
from = "XXX@company.co.nz"
to = ("QQQ@company.co.nz") 
subject= "TEST email 3" ;end;

 

 

Customer_Segment is defined further down in the program for each email to be sent , e.g.

 

%S_Letter (Letter_No='L02',
Customer_No='1234567890',
Account_No='nnnnnnnnnnnnnnnn001',
Customer_Segment='R',		 
Staff_No=222222,
Manager_Status='Vacant',   
Customer_Name='Donald Duck',  ;		



%S_Letter (Letter_No='L05',
Customer_No='1234567890',
Account_No='nnnnnnnnnnnnnnnn001',
Customer_Segment='S',		 
Staff_No=222222,
Manager_Status='Managed',   
Customer_Name='Mickey Mouse',  ;

 

 

My problem is that no matter what the Customer_Segment is it always sends every email to the last  address etc. as if no other variations have been coded .... so in the above example the letter to Donald Duck - Customer Segment 'R'  ... would get sent to QQQ@company.co.nz with subject line 'TEST email 3' .... instead of YYY@company.co.nz with subject line 'TEST email 1'

 

any help much appreciated !

1 REPLY 1
Reeza
Super User

Make a table with that information instead, even if you're creating it from a CARDS statement. Then build your recipient list from that table and feed that to your email program. 

 

I don't think file statements are conditional though, so you may need to make those macro %IF/%THEN or use a different method to create the file reference. There may be a function for that...

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 762 views
  • 0 likes
  • 2 in conversation