A PAUSE command is automatically issued whenever an execution error occurs, putting the module in a holding state. If you have some way of checking for specific errors, you can write an interrupt routine to correct them during the pause state.
In the following example, if a singular matrix is passed to the INV function, the IML procedure pauses and executes the pushed code to set the result for the inverse to missing values. The code uses the variable SINGULAR to detect if the interrupt occurred during the INV operation. This is particularly necessary because the pushed code is executed on completion of the routine, as well as on interrupts.
proc iml; a = {3 3, 3 3}; /* singular matrix */ /* If a singular matrix is sent to the INV function, */ /* IML normally sets the resulting matrix to be empty */ /* and prints an error message. */ b = inv(a); print "*** A should be non-singular", a; start singtest; msg=" Matrix is singular - result set to missing "; onerror= "if singular then do; b=a#.; print msg; print b; resume; end;"; call push(onerror); singular = 1; b = inv(a); singular = 0; finish ; call singtest;
The resulting output is as follows:
ERROR: (execution) Matrix should be non-singular. Error occurred in module SINGTEST at line 67 column 9 operation : INV at line 67 column 16 operands : A A 2 rows 2 cols (numeric) 3 3 3 3 stmt: ASSIGN at line 67 column 9 Paused in module SINGTEST. MSG Matrix is singular - result set to missing B . . . . Resuming execution in module SINGTEST.