Operations Research topics: SAS/OR,
SAS Optimization, and SAS Simulation Studio

How to stop Do loop not meeting stopping criterion automaticlly

Reply
N/A
Posts: 1

How to stop Do loop not meeting stopping criterion automaticlly

Hi,
If a Do loop in IML procedure never reaches its stopping criterion, it will keep running. Anyone knows how to stop the IML procedure automatically after a specified time and jump to next procedure?
Thanks in advance.

Luke
SAS Employee
Posts: 94

Re: How to stop Do loop not meeting stopping criterion automaticlly

You can program a time limit in the loop itself:

proc iml;
t0 = time(); /* units of the time() function are seconds */
time_limit = 5;
do while( (time()-t0)< time_limit);
x = 1; /* do your loop */
end;
print time_limit "elapsed time " (time() - t0);
Ask a Question
Discussion stats
  • 1 reply
  • 203 views
  • 0 likes
  • 2 in conversation