DATA Step, Macro, Functions and more

SAS Data step & Email procedure

Reply
N/A
Posts: 0

SAS Data step & Email procedure

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;
Frequent Contributor
Posts: 127

Re: SAS Data step & Email procedure

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
N/A
Posts: 0

Re: SAS Data step & Email procedure

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
Frequent Contributor
Posts: 127

Re: SAS Data step & Email procedure

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
Ask a Question
Discussion stats
  • 3 replies
  • 194 views
  • 0 likes
  • 2 in conversation