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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 784 views
  • 0 likes
  • 2 in conversation