how to customize the send mails personalization for each person, code is below , please anyone help on this .Where
-where we make changes on my code
-Customize for each person send message
EMP_ID | EMP_NAME | GENDER | BIRTHDAY | COMPANY | DESIGN | LOC | MAIL_ID |
100 | VENKATA | MALE | 24/11/22 | SAMA | DIRECTOR | PUNE | ravindranadh2125@gmail.com |
101 | MURALI | MALE | 24/11/22 | SAMA | DEVELOPER | PUNE | ravindranadh2125@gmail.com |
102 | PRABHAKAR | MALE | 24/11/22 | SAMA | DOMAIN | BANG | ravindranadh2125@gmail.com |
103 | PRASANNA | FEMALE | 24/11/22 | INFOTECH | PROGRAMMER | HYD | ravindranadh2125@gmail.com |
104 | RAMYA | FEMALE | 26/11/22 | DEVELOPER | KOCHI | ravindranadh2125@gmail.com | |
105 | MOUNIKA | FEMALE | 23/11/22 | MICROSOFT | PROGRAMMER | CHENNAI | ravindranadh2125@gmail.com |
106 | KIRAN | MALE | 26/11/22 | ACCENTURE | ANALYST | BANG | ravindranadh2125@gmail.com |
107 | NIKIL | MALE | 25/11/22 | WIPRO | DEVELOPER | MUMBAI | ravindranadh2125@gmail.com |
108 | MANOHAR | MALE | 24/11/22 | CYIENT | PROGRAMMER | HYD | ravindranadh2125@gmail.com |
109 | RAVINDRA | MALE | 26/11/22 | INFOSIS | ANALYST | PUNE | ravindranadh2125@gmail.com |
110 | PAVAN | MALE | 25/11/22 | SAMA | PROGRAMMER | CHENNAI | ravindranadh2125@gmail.com |
111 | RAMANI | FEMALE | 24/11/22 | ELI LILLY | DEVELOPER | KOCHI | ravindranadh2125@gmail.com |
options unbuflog;
proc import datafile="/home/u61914035/import files/birthdayXL.xlsx"
dbms=xlsx
out=ds
replace;
run;
data staff;
set ds;
informat BIRTHDAY ddmmyy10.;
format BIRTHDAY date9.;
where BIRTHDAY ne .;
todays=put(today(),date9.);
run;
data bday_today;
set staff;
bday=substr(put(BIRTHDAY,date9.),1,5);
tday=upcase(substr(todays,1,5));
if bday=tday;
run;
proc sql;
select count(distinct MAIL_ID) into :emailcnt from bday_today;
%let emailcnt = %cmpres(&emailcnt);
select distinct MAIL_ID into :email1 - :email&emailcnt from bday_today;
quit;
%macro mail;
%if &emailcnt gt 0 %then
%do i = 1 %to &emailcnt;
filename Myemail email
from = "ravindranadh044@gmail.com"
subject = "!!! BIRTHDAY ALERT !!!"
attach=("/home/u61914035/import files/0d01cc9cebe2e8de8b60d8fbf6ee47bc.gif")
to = "&&email&i"
type = "text/html";
data null;
file Myemail;
set bday_today(where = (MAIL_ID="&&email&i"));
put 'HAPPY BIRTHDAY' ;
RUN;
%end;
%mend;
%mail;
how to customize the text or document through mail to each persons who have bdays automatically without running the program daily...
EMP_ID | EMP_NAME | GENDER | BIRTHDAY | COMPANY | DESIGN | LOC | MAIL_ID |
100 | VENKATA | MALE | 24/11/22 | SAMA | DIRECTOR | PUNE | ravindranadh2125@gmail.com |
101 | MURALI | MALE | 24/11/22 | SAMA | DEVELOPER | PUNE | ravindranadh2125@gmail.com |
102 | PRABHAKAR | MALE | 24/11/22 | SAMA | DOMAIN | BANG | ravindranadh2125@gmail.com |
103 | PRASANNA | FEMALE | 24/11/22 | INFOTECH | PROGRAMMER | HYD | ravindranadh2125@gmail.com |
104 | RAMYA | FEMALE | 26/11/22 | DEVELOPER | KOCHI | ravindranadh2125@gmail.com | |
105 | MOUNIKA | FEMALE | 23/11/22 | MICROSOFT | PROGRAMMER | CHENNAI | ravindranadh2125@gmail.com |
106 | KIRAN | MALE | 26/11/22 | ACCENTURE | ANALYST | BANG | ravindranadh2125@gmail.com |
107 | NIKIL | MALE | 25/11/22 | WIPRO | DEVELOPER | MUMBAI | ravindranadh2125@gmail.com |
108 | MANOHAR | MALE | 24/11/22 | CYIENT | PROGRAMMER | HYD | ravindranadh2125@gmail.com |
109 | RAVINDRA | MALE | 26/11/22 | INFOSIS | ANALYST | PUNE | ravindranadh2125@gmail.com |
110 | PAVAN | MALE | 25/11/22 | SAMA | PROGRAMMER | CHENNAI | ravindranadh2125@gmail.com |
111 | RAMANI | FEMALE | 24/11/22 | ELI LILLY | DEVELOPER | KOCHI | ravindranadh2125@gmail.com |
options unbuflog;
proc import datafile="/home/u61914035/import files/birthdayXL.xlsx"
dbms=xlsx
out=ds
replace;
run;
data staff;
set ds;
informat BIRTHDAY ddmmyy10.;
format BIRTHDAY date9.;
where BIRTHDAY ne .;
todays=put(today(),date9.);
run;
data bday_today;
set staff;
bday=substr(put(BIRTHDAY,date9.),1,5);
tday=upcase(substr(todays,1,5));
if bday=tday;
run;
proc sql;
select count(distinct MAIL_ID) into :emailcnt from bday_today;
%let emailcnt = %cmpres(&emailcnt);
select distinct MAIL_ID into :email1 - :email&emailcnt from bday_today;
quit;
%macro mail;
%if &emailcnt gt 0 %then
%do i = 1 %to &emailcnt;
filename Myemail email
from = "ravindranadh044@gmail.com"
subject = "!!! BIRTHDAY ALERT !!!"
attach=("/home/u61914035/import files/0d01cc9cebe2e8de8b60d8fbf6ee47bc.gif")
to = "&&email&i"
type = "text/html";
data null;
file Myemail;
set bday_today(where = (MAIL_ID="&&email&i"));
put 'HAPPY BIRTHDAY' ;
RUN;
%end;
%mend;
%mail;
Please don't post questions multiple times.
Please post data in usable form: a data step using datalines.
When posting code, please use "insert sas code" (the button with the running person) and post properly formatted code only.
Form your description i don't understand what you want to achieve.
proc import datafile="/home/u61914035/import files/birthdayXL.xlsx" dbms=xlsx out=ds replace; run; data staff; set ds; informat BIRTHDAY ddmmyy10.; format BIRTHDAY date9.; where BIRTHDAY ne .; todays=put(today(),date9.); run; data bday_today; set staff; bday=substr(put(BIRTHDAY,date9.),1,5); tday=upcase(substr(todays,1,5)); if bday=tday; run; proc sql; select count(distinct MAIL_ID) into :emailcnt from bday_today; %let emailcnt = %cmpres(&emailcnt); select distinct MAIL_ID into :email1 - :email&emailcnt from bday_today; quit; %macro mail; %if &emailcnt gt 0 %then %do i = 1 %to &emailcnt; filename Myemail email from = "ravindranadh044@gmail.com" subject = "!!! BIRTHDAY ALERT !!!" attach=("/home/u61914035/import files/0d01cc9cebe2e8de8b60d8fbf6ee47bc.gif") to = "&&email&i" type = "text/html"; data null; file Myemail; set bday_today(where = (MAIL_ID="&&email&i")); put 'HAPPY BIRTHDAY' ; RUN; %end; %mend; %mail;
All mail_id seem to be identical, so you would only send one email anyway.
Simple approach:
Create a macro which sends one email to one person. It should accept the email address as parameter.
Then read yor initial dataset, and for every observation where day(birthday) = day(today()) and month(birthday) = month(today()) call the macro with CALL EXECUTE.
Please look into this problem
Define "customize". Show examples of the text for different persons. Provide example data supplying the items for customization.
For code, provide example data in a data step with datalines. DO NOT SKIP THIS.
data ds;
infile datalines;
input EMP_ID EMP_NAME$ GENDER$ BIRTHDAY COMPANY$ DESIGN$ LOC $ MAIL_ID$ 1 -26;
cards;
100 venkata male 27/11/2022 sama director pune ravindranadh2125@gmail.com
101 murali male 28/11/2022 sama teamlead pune ravindranadh2125@gmail.com
102 prabhkar male 27/11/2022 sama manager pune ravindranadh2125@gmail.com
103 prasanna female 27/11/2022 infotech juniordev hyd ravindranadh2125@gmail.com
104 ramya female 27/11/2022 infotech juniordev chennai ravindranadh2125@gmail.com
105 mounika female 28/11/2022 google juniordev hyd ravindranadh2125@gmail.com
106 kiran male 29/11/2022 google juniordev hyd ravindranadh2125@gmail.com
107 nikhil male 28/11/2022 cyient juniordev bang ravindranadh2125@gmail.com
108 manohar male 28/11/2022 infosis juniordev bang ravindranadh2125@gmail.com
109 ravindra male 27/11/2022 infosis juniordev hyd ravindranadh2125@gmail.com
110 pavan male 27/11/2022 sama juniordev pune ravindranadh2125@gmail.com
111 ramani male 27/11/2022 eli llily juniordev vizag ravindranadh2125@gmail.com
;
run;
proc import datafile="/home/u61914035/import files/birthdayXL.xlsx" dbms=xlsx out=ds replace; run; data staff; set ds; informat BIRTHDAY ddmmyy10.; format BIRTHDAY date9.; where BIRTHDAY ne .; todays=put(today(),date9.); run; data bday_today; set staff; bday=substr(put(BIRTHDAY,date9.),1,5); tday=upcase(substr(todays,1,5)); if bday=tday; run; proc sql; select count(distinct MAIL_ID) into :emailcnt from bday_today; %let emailcnt = %cmpres(&emailcnt); select distinct MAIL_ID into :email1 - :email&emailcnt from bday_today; quit; %macro mail; %if &emailcnt gt 0 %then %do i = 1 %to &emailcnt; filename Myemail email from = "ravindranadh044@gmail.com" subject = "!!! BIRTHDAY ALERT !!!" attach=("/home/u61914035/import files/0d01cc9cebe2e8de8b60d8fbf6ee47bc.gif") to = "&&email&i" type = "text/html"; data null; file Myemail; set bday_today(where = (MAIL_ID="&&email&i")); put 'HAPPY BIRTHDAY' ; RUN; %end; %mend; %mail;
Your code will send identical mails to all recipients, there is no customization.
Show examples for the mails you want.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.