BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SASdevAnneMarie
Barite | Level 11

Hello!

I have a question.

In my table SAS, the column CODE_PRODUIT hase the values: CD1, CD2, CD3, CD4. This values can change.

I would like that this values appear in my e-mail, like this:

 

FILENAME outmail EMAIL
SUBJECT= "PRODUCT"
type='text/html'  

FROM= ‘XXXX’

TO=  (‘XXXX’‘XXXX’)

CC=(‘XXXX’)

data _null_;

file outmail;

if _N_=1 then

     do;

PUT '<html>'"Hello,"'</html>';

PUT '<html>'"The values are:"'</html>';

PUT '<html>'"-CD1"'</html>'; /***new line***/

PUT '<html>'"-CD2"'</html>'; /***new line***/

PUT '<html>'"-CD3"'</html>'; /***new line***/

PUT '<html><br></html>';

end;

run;

 

My question is: do you know some option to resolve the macro variable in html message?

 

My code doesn't work: I can't resolve the macro variable &liste_PRODUIT2. in my e-mail:

 

data CODE_PRODUIT2;

     set CODE_PRODUIT;

     code_1="PUT'<html>'";

     code_2=quote('A0'x||'A0'x||'A0'x||("-")||(CODE_PRODUIT));

     code_3="'</html>';";

     CODE_PRODUIT_2=compress(code_1||code_2||code_3);

run;

 

proc sql noprint;

     select distinct strip(CODE_PRODUIT_2) into :liste_PRODUIT2 separated by ''

           from CODE_PRODUIT2;

quit;

 

%put "&liste_PRODUIT2.";

 

data _null_;
file outmail;

if _N_=1 then
do;

PUT '<html>'"Hello,"'</html>';

PUT '<html>'"The values are:"'</html>';

PUT '<html><br></html>';
%put &liste_PRODUIT2.
PUT '<html><br></html>';
PUT '<html><br></html>';
PUT '<html><br></html>';

end;
run;

 

Thank ypu for you help!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Don't use a %PUT macro statement to output data to the FILE destination. %PUT writes only to the log.

data _null_;
file outmail;
if _N_=1 then
do;
  PUT '<html>'"Hello,"'</html>';
  PUT '<html>'"The values are:"'</html>';
  PUT '<html><br></html>';
  put "&liste_PRODUIT2.";
  PUT '<html><br></html>';
  PUT '<html><br></html>';
  PUT '<html><br></html>';
end;
run;

View solution in original post

5 REPLIES 5
Kurt_Bremser
Super User

Don't use a %PUT macro statement to output data to the FILE destination. %PUT writes only to the log.

data _null_;
file outmail;
if _N_=1 then
do;
  PUT '<html>'"Hello,"'</html>';
  PUT '<html>'"The values are:"'</html>';
  PUT '<html><br></html>';
  put "&liste_PRODUIT2.";
  PUT '<html><br></html>';
  PUT '<html><br></html>';
  PUT '<html><br></html>';
end;
run;
SASdevAnneMarie
Barite | Level 11
Thank you very much Kurt!
It works!
Marie
SASdevAnneMarie
Barite | Level 11

I have a little problem with my macro variable, I receive this in my e-mail (via html message):

 

. -T340GB     

-T341GB     

-T387GB     

 

I try to delete the dot on the first line, but I suppose it is an html issue.

Do you have please some options for that?

Thank you very much! 

ballardw
Super User

@SASdevAnneMarie wrote:

I have a little problem with my macro variable, I receive this in my e-mail (via html message):

 

. -T340GB     

-T341GB     

-T387GB     

 

I try to delete the dot on the first line, but I suppose it is an html issue.

Do you have please some options for that?

Thank you very much! 


One strongly suspects that your code is Putting a missing value. You may resolve that by placing this line before the data step that writes to the file:

 

options missing=' ';  (yes that is a single space between the quotes).

 

Then any missing value will display as a blank.

You should reset the option back to the dot after the step. Otherwise you may get confused when you no longer see dots for missing values.

SASdevAnneMarie
Barite | Level 11

Hello,

 

Thank you very much, that works!

 

Best regards,

Marie

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
  • 5 replies
  • 1935 views
  • 1 like
  • 3 in conversation