You can check the macro variable SYSCC.  SYSCC is going to capture about 90% of errors.  After an SQL call, you can check SQLRC.
 
Something like this:
%MACRO Check_RC;
    %GLOBAL SQLRC;
    %IF  &SYSCC >= 8 OR
        &SQLRC >= 8 %THEN
        %DO;
            (Send an email here or whatever you think appropriate)
        %END;
%MEND;
You have to declare SQLRC but SYSCC is always present.
 
Then after each Data or Proc step you would code the following:
%Check_RC;
However, there are a few Errors in SAS that for whatever reason do not get captured in the SYSCC.  What I do is look at the SYSERRORTEXT macro variable and compare it to a copy I have saved.  If SYSERRORTEXT is not blank and is not equal to the value from the last time I executed %Check_RC, then I also consider that an error even if SYSCC is still zero.  A zero return code is considered good.  A 4 is considered a warning.  An 8 or greater is considered an error.  Occasionally there are some values of 1, but those are mostly in another status variable, SYSFILRC.
 
Jim