I'd like to write code that checks the SAS log for errors/warnings. If there are no errors/warnings throughout the code, I'd like to send an email with the results. I am aware that something similar is possible in SAS Management Console, where an exit code is produced i.e. return code = 0 (success), return code = 1 (warning), return code = 2 (error). In this particular example, I am not working with a batch process, and I'd like to customize the email that is sent to emails, so I'd like to perform this task in SAS Enterprise Guide. Recreating a customized version of the SAS Management Console return codes, and create logic that is only executed if the return code = 0, could be a good solution. I have come across SAS community posts utilizing the syserr & syserrortext macro variables. However, I'm looking for an approach that checks an entire SAS program, as opposed to an error check after each individual data/proc step. Maybe there's a way to read the SAS log file, count the number of occurences of the string 'ERROR:" and "WARNING:", and create a condition where code is performed where errors and warnings are equal to zero. Unfortunately, I couldn't find anything that worked for me online. I'm thinking of something like this: /*Email setup*/ filename outbox email from = 'my.email@gmail.com' to = 'your.email@gmail.com' subject = "Results" attach = "C:\temp\results.csv" ; /*Send email if there are no errors/warnings*/ %macro error_check; %if &number_of_errors. = 0 and &number_of_warnings. = 0 %then %do; data _null_; file outbox; put "Hi,"; put ; put "Customized message to the relevant stakeholders."; put ; put "Thanks,"; put "Josh"; run; %end; %mend; %error_check;
... View more