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 !
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...
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.
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.