/* macro to email a file to a list */
%macro EmailFile;
/* This creates a series of macro variables to send email to
individuals. */
proc sort data=work.TEST1 out=list(keep=ShopName MAIL FISBUYUMESI FISBUYUMESIYTD SATISADETBUYUMESI SATISADETBUYUMESIYTD CIROBUYUMESI CIROBUYUMESIYTD SEPETADETBUYUMESI SEPETADETBUYUMESIYTD CONQUESTBUYUMESI CONQUESTBUYUMESIYTD CONVRATEBUYUMESI CONVRATEBUYUMESIYTD) nodupkey;
by MGZID;
run;
data _null_;
set list end=last;
call symput(compress('MAIL'||_n_),MAIL);
call symput(compress('ShopName'||_n_),ShopName);
call symput(compress('FISBUYUMESI'||_n_),PUT(FISBUYUMESI,PERCENTN8.2));
call symput(compress('FISBUYUMESIYTD'||_n_),PUT(FISBUYUMESIYTD,PERCENTN8.2));
call symput(compress('SATISADETBUYUMESI'||_n_),PUT(SATISADETBUYUMESI,PERCENTN8.2));
call symput(compress('SATISADETBUYUMESIYTD'||_n_),PUT(SATISADETBUYUMESIYTD,PERCENTN8.2));
call symput(compress('CIROBUYUMESI'||_n_),PUT(CIROBUYUMESI,PERCENTN8.2));
call symput(compress('CIROBUYUMESIYTD'||_n_),PUT(CIROBUYUMESIYTD,PERCENTN8.2));
call symput(compress('SEPETADETBUYUMESI'||_n_),PUT(SEPETADETBUYUMESI,PERCENTN8.2));
call symput(compress('SEPETADETBUYUMESIYTD'||_n_),PUT(SEPETADETBUYUMESIYTD,PERCENTN8.2));
call symput(compress('CONQUESTBUYUMESI'||_n_),PUT(CONQUESTBUYUMESI,PERCENTN8.2));
call symput(compress('CONQUESTBUYUMESIYTD'||_n_),PUT(CONQUESTBUYUMESIYTD,PERCENTN8.2));
call symput(compress('CONVRATEBUYUMESI'||_n_),PUT(CONVRATEBUYUMESI,PERCENTN8.2));
call symput(compress('CONVRATEBUYUMESIYTD'||_n_),PUT(CONVRATEBUYUMESIYTD,PERCENTN8.2));
if last then call symput('tot',trim(left(_n_)));
run;
/* cycle through the individual emails to send the messages */
%do i=1 %to &tot;
/* if you want to attach a file use the filename statement
and the pathname function to capture the location
of the file */
/*filename freq "&fn.crr.csv";
%let path=%sysfunc(pathname(freq));
ods csv file=freq;
proc print data=freqstart noobs;
run;
ods csv close;
/* set options for email and use the filename statement
with the email option to send email */
options emailhost=(xxxxxxx);
filename mymail email "&&MAIL&i"
subject="MAGAZA BUYUME ORANLARI ";
/*attach="&path";*/
/* Add some text to the email */
data _null_;
file mymail;
put " Fis Buyumesi: &&FISBUYUMESI&i ";
put " Fis BuyumesiYTD: &&FISBUYUMESIYTD&i"/n;
put " Satis Buyumesi: &&SATISADETBUYUMESI&i";
put " Satis BuyumesiYTD: &&SATISADETBUYUMESIYTD&i"/n;
put " Sepet Buyumesi: &&SEPETADETBUYUMESI&i";
put " Sepet BuyumesiYTD: &&SEPETADETBUYUMESIYTD&i"/n;
put " Ciro Buyumesi : &&CIROBUYUMESI&i";
put " Ciro BuyumesiYTD : &&CIROBUYUMESIYTD&i"/n;
put " Kart Acilis Buyumesi: &&CONQUESTBUYUMESI&i";
put " Kart Acilis BuyumesiYTD: &&CONQUESTBUYUMESIYTD&i"/n;
put " Magaza Donusum Buyumesi: &&CONVRATEBUYUMESI&i";
put " Magaza Donusum BuyumesiYTD:&&CONVRATEBUYUMESIYTD&i"/n;
put " *YTD: Yil icerisindeki toplam buyume degerini temsil etmektedir.";
run;
%end;
%mend;
%EmailFile
hi ,
I want to design a code that will mail each store their own growth rates. the code works as follows. but we also want to add the number of baskets to the seller. I want to send two different data with a single mail. I can't join because the lines are multiplied. but my ID field is common in both tables.
how can I do it. my first table is based on a single line, while my second table should send rows with all employees working in that store.
thank you:)
You may put in a dataset and email as a table in html format. See sample code below:
options emailhost=(xxxxxxx);
filename myemail EMAIL TO=(&&MAIL&i)
CONTENT_TYPE="text/html"
subject="MAGAZA BUYUME ORANLARI ";
ODS HTML BODY=myemail;
ods html text='<div align="Left">Hi All,</div> <BR>';
ods html text='<div align="Left">Data as below </div> <BR>';
PROC PRINT DATA=YOURDATASETNUMBER1; RUN ;
PROC PRINT DATA=YOURDATASETNUMBER2; RUN ;
ods html text='<BR><div align="Left"> Any text </div> <BR>';
ods html text='<div align="Left">Any text </div> <BR>';
ods html text='<div align="Left">Any text </div> <BR>';
ODS HTML CLOSE;
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: