First you need to understand the relationship between the macro pre-processor and actual SAS code.
You use macro code to generate SAS code. Once SAS sees a full step it runs it.
So you ran these statements:
%let tomail=No Errors No Warning;
%let tomail=Warning found;
%let tomail=Error found ;
data _null_;
set noerr;
if substr(alert,1,4)='NOTE' then do;
end;
if substr(alert,1,5)='WARNI' then do;
end;
if substr(alert,1,5)='ERROR' then do;
end;
run;
Second it looks like your sample data has multiple observations, but you are generating only one macro variable. So you need to have logic that reflects that.
data _null_;
set noerr end=eof;
if alert=:'WARNI' then warnings+1;
if alert=:'ERROR' then errors+1;
if eof then do;
if errors then call symputx('tomail','Errors found');
else if warnings then call symputx('tomail','Warnings found');
else call symputx('tomail','No Errors or Warnings');
end;
run;
... View more