I want SAS to send an email out, but only if a global macro variable &warning is equal to 1.
Is this possible? I'm trying the following, but it's not working. It still sends an email when warning=0.
filename outbox email
to=('me@myemail.com')
subject='Warning Report'
from='you@myemail.com'
attach='/report.html';
DATA _null_;
file outbox;
Put "Hello,"//
"Warning report attached."//
"Regards,"/
"Chris";
if &warning. =1
run;
I think it's because you don't use then, even thereI think there will be a syntax issue and SAS will not be able to finish that code block or return an error.... You can put it in a macro and it will work.
try something like this
%macro email(condition=);
%if &condition.=1 %then %do;
filename outbox email
to=('me@myemail.com')
subject='Warning Report'
from='you@myemail.com'
attach='/report.html';
DATA _null_;
file outbox;
Put "Hello,";
Put "Warning report attached.";
Put "Regards,";
Put "Chris";
run;
%end;
%mend;
%email(condition=&warning.);