BookmarkSubscribeRSS Feed
MDaniel
Obsidian | Level 7

I am loogin at implementing a generic process of error handling on all the IML scripts we run in our company. Ideally, it would be something like this:

%LET IsIMLError = 0; /* flag that is set to 1 in case if an error */

proc iml;

OnError do;  /* is this somehow possible? */
   %LET IsIMLError = 1; 
   write_error_to_text_file; /* pseudo-code */
   ABORT;
end;

/* IML code goes here*/

quit;

 

The idea is to always trigger the error handling section whenever an error appears, no matter the nature of the error. Right now I can't figure out if the 'OnError' event exists in SAS/IML (or something with similar functionality). Any hints?

1 REPLY 1
Rick_SAS
SAS Super FREQ

Read the doc chapter "Generating and Executing Statements", which has two sections on error handling. 

Be sure you are also familiar with the ways to handle run-time errors in modules.

 

If I may offer some advice: Whenever possible, it is better, easier, and cleaner to detect and handle SAS/IML errors BEFORE they occur. This is different than the try/catch paradigm in some other languages.  

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 1 reply
  • 969 views
  • 1 like
  • 2 in conversation