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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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