filename mylog1 "/sasdata/user_Data/log.log";
proc printto log=log;
run;
data _null_;
infile mylog1 ;
input;
put _infile_;
run;
Rather than looking af the SYSERR Automatic variable, I would use the SYSCC variable.
It has two advantages:
So I would start with
%let SYSCC=0;
SAS CODE here
%let check=&SYSCC;
Then, after the SAS code submitted, &SYSCC contains the maximum error level encountered, which you save in your CHECK variable.
In which case you may want to change the "if &check>0 then do;" in your log gathering datastep to "if &check>4 then do;" as level 4 is just a Warning, and apparently you do not want to report those.
I do not see how you send your mail, allocating the EMAIL file is not enough. So I presume that you have a datastep in the end to send the mail. If things are OK, and you do not want to send the mail, just put this in your datastep:
Data _null_;
file outbox <options>;
if &check<=4 then do;
put "!EM_ABORT!";
stop;
end;
The !EM_ABORT! message tells SAS not to send the mail after all.
Thanks @s_lassen I'll try this. By the way, the email is sent by the code:
filename outbox email attach=("/sasdata/user_Data/reportlog.txt") importance='high'
to='chrodriguez@com.do'
type='text/html'
subject= "Log ETL"
from='planificacion@com.do';
DATA _NULL_;
FILE outbox;
PUT "<body>";
PUT "<p>Hello, </p>";
PUT "<p>The program executed with erros, see attached file.</p>";
PUT "<p>Regards.</p>";
PUT "</body>";
run;
run;
The file attached contains only the errors and warning messages from the log.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.