Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop SAS Program on Error

Tags:

sas

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?

like image 618
Nick Nelson Avatar asked Nov 05 '22 04:11

Nick Nelson


1 Answers

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.

like image 63
user667489 Avatar answered Nov 09 '22 15:11

user667489