I am using a macro to stop my SAS program on an error, but it always disconnects from the server and then I cannot get back my temporary data sets anymore.
I have tried:
OPTIONS ERRORABEND;
Here is the macro I have tried:
%macro errchk;
%if &syserr >0 and &syserr ne 4 %then %abort;
%mend errchk;
This one keeps processing the following data steps after reaching an error.
I cannot figure out how to stop the rest of the program from running, but NOT disconnect from the SAS server. Any ideas?
Have you tried using %goto? Rather than triggering an abort, you can redirect your macro to an exit point, and print something to the log to indicate which part of your code failed.
An example of the syntax is given here:
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a000209058.htm
I think the problem with %errchk above is probably that the %abort statement applies only to %errchk itself. If you placed %abort calls in the middle of your macro code without wrapping them in another macro you might have more success with that approach. Or you could do something to delay execution of the %abort until %errchk has already completed - perhaps by enclosing it in a %nrstr()? Let me know if this works - I'll be able to test it tomorrow.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With