BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
saswiki
Obsidian | Level 7

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.

1 ACCEPTED SOLUTION

Accepted Solutions
s_lassen
Meteorite | Level 14

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;

View solution in original post

3 REPLIES 3
Patrick
Opal | Level 21

Can you please share your current code that creates the email.

saswiki
Obsidian | Level 7

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;

s_lassen
Meteorite | Level 14

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;

SAS Innovate 2025: Register Now

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!

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
  • 3 replies
  • 997 views
  • 2 likes
  • 3 in conversation