Hi Experts,
I have a scenario where i have to add the table values as email body but i am not able to do it for multiple lines.
Here is the SAS dummy program.
data test;
infile datalines;
input part $ bldg $ area $ po $;
datalines;
A1 FR KIT XX1
A2 W KIT XX1
A3 FR LOIN XX4
C3 FR KIT XX6
;
run;
and the email body should be : This can be n number of observations. Can anyone help me to get this looped.
A1 is routed to FR KIT but does not have a coordinate on XX1.Determine the correct coordinate and add it.
A2 is routed to W KIT but does not have a coordinate on XX1.Determine the correct coordinate and add it.
A3 is routed to FR LOIN but does not have a coordinate on XX4.Determine the correct coordinate and add it.
C3 is routed to FR KIT but does not have a coordinate on XX6.Determine the correct coordinate and add it.
I do not think you should loop the macro variables for the email content, just read the data, something like this:
DATA _NULL_;
FILE BLAT;
set test end=done:
if _N_=1 then
put "Team,<BR><BR>";
PUT part "is routed to " bldg. area "but does not have a coordinate on " po ". Determine the correct coordinate and add it. <BR>";
if done;
PUT "<BR><BR>";
PUT "Regards,<BR><BR>";
RUN;
Can you please share your current code that creates the email.
I am not sure how to loop the macro values,
The below code i tried but it reads only first value in the macro.
data test;
infile datalines;
input part $ bldg $ area $ po $;
datalines;
A1 FR KIT XX1
A2 W KIT XX1
A3 FR LOIN XX4
C3 FR KIT XX6
;
run;
proc sql;
select part into: part_list from test;
quit;
proc sql;
select bldg into: bldg_list from test;
quit;
proc sql;
select area into: area_list from test;
quit;
proc sql;
select po into: po_list from test;
quit;
%put &date.;
OPTIONS EMAILSYS=SMTP EMAILHOST=intramail.cis.cat.com EMAILID="test@mail.com";
FILENAME BLAT EMAIL
FROM = ( "test@mail.com" )
TO = ("rec@mail.com" )
SUBJECT = ("&subject.– &date")
TYPE = "TEXT/HTML"
;
DATA _NULL_;
FILE BLAT;
put "Team,<BR><BR>";
PUT "&part_list. is routed to &bldg_list. &area_list but does not have a coordinate on &po_list..Determine the correct coordinate and add it.
<BR><BR>";
PUT " ";
PUT "Regards,<BR><BR>";
RUN;
I do not think you should loop the macro variables for the email content, just read the data, something like this:
DATA _NULL_;
FILE BLAT;
set test end=done:
if _N_=1 then
put "Team,<BR><BR>";
PUT part "is routed to " bldg. area "but does not have a coordinate on " po ". Determine the correct coordinate and add it. <BR>";
if done;
PUT "<BR><BR>";
PUT "Regards,<BR><BR>";
RUN;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.