BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
richard_hu2003
Calcite | Level 5

Hi Folks,

I have the following IML code in a large macro called %LARGE. Of course, there are other command lines within OOPS module. I want to exit IML and go to label "doit" if there is any error when executing IML. But it falied to execute %goto statement. Could anybody help? Thanks.

proc iml;

start;                                          /* module will be named MAIN */
errcode = {" %if errors >= 0 %then %goto doit ; "} ;
call push (errcode);
errors = 0;

  

   start oops;                             /* start module OOPS */

   .......

   .......

   finish;                                     /* finish OOPS */
   run oops;

finish;                                       /* finish MAIN */


errors= -1;                                /* disable     */
quit;

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

An interesting question. I've never done it. You might try this (I don't know whether it will work):

1) Before PROC IML, use %LET IsError = 0;

2) In PROC IML, if there is an error CALL SYMPUT("IsError", "1"); and then ABORT;

3) After the PROC IML code, use a %IF statement to check the value of &IsError. If it is set, then %GOTO.

View solution in original post

4 REPLIES 4
Rick_SAS
SAS Super FREQ

Have you looked at

http://communities.sas.com/message/37481#37481 ?

It is a slightly different problem, but related, and it includes a complete example that you can run. Also, it points out that the 'doit' label must be within the OOPS module.

richard_hu2003
Calcite | Level 5

Hi Rick.

Thanks for your reply. If it encounters errors, I want it %goto 'doit' label which is outside the IML procedure and skip other steps inside IML. Is there a nice way to do that? Thanks.

Rick_SAS
SAS Super FREQ

An interesting question. I've never done it. You might try this (I don't know whether it will work):

1) Before PROC IML, use %LET IsError = 0;

2) In PROC IML, if there is an error CALL SYMPUT("IsError", "1"); and then ABORT;

3) After the PROC IML code, use a %IF statement to check the value of &IsError. If it is set, then %GOTO.

richard_hu2003
Calcite | Level 5

Thanks, Rick!

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
  • 4 replies
  • 1216 views
  • 5 likes
  • 2 in conversation