SYSERR Automatic Macro Variable
<p>I have several programs in one SAS project, i.e program A -> program B ->.... I want to build dependency between programs using macro variables.</p>

<p>Program A will process few data step and procs. If <strong>ANY</strong> procedure in program A executes with errors, I would like to run program C. Otherwise run program B.</p>

<p>This seems to be tricky since <code>syserr</code> resets at each step boundary. If first data step in program A executes with error and the rest don't, then at the end of program A, <code>syserr</code> is still <code>0</code>. I need macro variable value to be something other than 0 once error happens and the value can keep till program ends.</p>

<p>If the program dependency is based on other criteria (say values), the user-defined macro variables can handle that. For something related to system errors, I think SAS already has something can do the trick.But I can't find anything else except <code>syserr</code>, which doesn't seem to help.</p>

<p>Note: I find this <a href="https://stackoverflow.com/questions/9009944/is-there-a-way-to-make-sas-stop-upon-the-first-warning-or-error">SAS stop on first error</a>. But basically it's to check the error status after each data step. That sounds crazy if program A contains 50+ data steps.</p>