BookmarkSubscribeRSS Feed
JJP1
Pyrite | Level 9

hi, i am running the below user written code in SAS DI job and i am getting error please suggest

 

%let Email_Address=;
proc sql noprint;
select distinct cat('"',strip(Email_Address),'"')
into :Email_Address
separated by ' '
from yyyyy
;
quit;
%if %eval(&syscc > 0) %then %return;
%put Email_Address = &Email_Address;
%macro send_email;
%if &Email_Address ne %then %do;
filename email email
from=('xxxxxxx.com')
sender=('xxxxxxx.com')
to=(&Email_Address)
cc=('rrrrrrr.com' 'xxxxxxx.com' 'CCCCCC.com')
subject=('cccccccccccccccccccccccc')
importance='high'
type='text/html'
CT ='text/html'
;
title;
ods html body=email;
ods html text='Hello';
ods html text=' ';
ods html text='gggggggggggggggggggggggggggggggggggg';
ods html text=' ';
ods html text='uyuuuuuuuuuuuuuuuuuuuu.';
ods html text=' ';
ods html text='ccccccccccccccccccccccccccccc xxxxxxx.com .';
ods html text=' ';
ods html text='iiiiiiiiiiiiiiiiiiiiiiiiiiiiiit';
ods html text=' ';
proc print data=output1 label noobs;quit;
%if %eval(&syscc > 0) %then %return;
ods html text=' ';
ods html text='Thanks';
ods html text='XXXXXXXXXXXXXXX';
ods html text='Email: xxxxxxx.com';
ods _all_ close;
%end;
%mend;
%send_email;



JJP1_0-1600670267153.png

 

 

6 REPLIES 6
Kurt_Bremser
Super User

Since SAS 9.4M5, you can use %IF-%THEN-%DO-%END in open code, but not %IF-%THEN without the %DO-%END.

Expand this

%if %eval(&syscc > 0) %then %return;

to this

%if %eval(&syscc > 0) %then %do; %return; %end;
JJP1
Pyrite | Level 9

Thanks @Kurt_Bremser .

but iam still getting error after expanding the code as you suggested. would you pleas correct me

JJP1_0-1600680443269.png

 

andreas_lds
Jade | Level 19

Please verify that you are using at least 9.4m5.

JJP1
Pyrite | Level 9

I am using SAS DI 4.4 application please

Astounding
PROC Star

Just a few notes about things you willl need to clean up sooner or later ...

 

First, don't define %SEND_EMAIL inside an %IF %THEN condition.  Pull out the definition of the macro so it stands alone.  The other logic can still call %SEND_EMAIL.  That will make your logic easier to understand and debug.

 

Second, what is the first %RETURN statement supposed to do?  Even if you solve for %IF in open code, there is no way to make a %RETURN statement valid outside of a macro definition.

 

Finally, beware of this comparison: 

%if &Email_Address ne %then %do;

Some email addresses contain a dash.  If that occurs, macro language will interpret that as subtraction and give you an error message.  Safer:

%if %length(&Email_Address) %then %do;

 

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
  • 6 replies
  • 2283 views
  • 1 like
  • 4 in conversation