BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi All, currently im doing some project to send out email from a list(.csv) in EG.
However, im not able to pass parameter out into Send_Mail Macro.
And i received an error message:
(WARNING: Email: 553 @yahoo.com.my... Recipient Incorrect Format
ERROR: Bad email address: EMAIL)


libname temp 'D:\Report\Temp';
FILENAME myemail EMAIL from="a.apple@yahoo.com.my";

data Temp_Email;
set temp.email_list;
format Email $quote150.;
%Send_Mail(Email); <<--------------Error in this section
run;

%macro Send_Mail(Primary_Email);

data _null_;

file myemail

to=(&Primary_Email) <<--------------Value from Datastep
subject = "An automatic email sent from SAS";

put "Your report is now available online."
/ / "Thank you and have a great day."
/ / " "
/ /"Sincerely,"
/ /"Mr A"
/ / " "
/ / "This is an automated email sent by SAS on behalf of ABC";
run;
%mend;
3 REPLIES 3
Florent
Quartz | Level 8
Hi,

You should have a look at the CALL EXECUTE statement.
In your example it would be used that way:

data Temp_Email;
set temp.email_list;
format Email $quote150.;
CALL EXECUTE('%Send_Mail('||Email||')');
run;

I hope it helps.

Regards,
Florent
deleted_user
Not applicable
Hi Florent,
Thx for your reply. It is working now.

However, i had found out a problem whereby when i run macro 1st time, this error message prompted out

WARNING: Apparent invocation of macro SEND_MAIL not resolved.

After that, i tried run 2nd time and i got error free. No problem sending email out.
I guess the data step is not created yet and the macro had been call execute.

Can i know which area should i enhance it?

Million thanks
Florent
Quartz | Level 8
Hi,

Indeed, the macro definition (%macro send_mail) should appear before the datastep in which you make the calling to this macro.

Kind regards,
Florent

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 1252 views
  • 0 likes
  • 2 in conversation