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;
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;
Thanks @Kurt_Bremser .
but iam still getting error after expanding the code as you suggested. would you pleas correct me
Please verify that you are using at least 9.4m5.
I am using SAS DI 4.4 application please
We need to know the backend SAS version, not the version of the frontend. Run this
%put &sysvlong;
or
proc setinit;
run;
and look at the log.
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;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.