Statistical programming, matrix languages, and more

How do I improve performance for a slow IML based simulation code?

Reply
Occasional Contributor
Posts: 11

How do I improve performance for a slow IML based simulation code?

I have a very slow running simulation code that uses IML. Although I am generating 10,000 samples for every iteration, I need to retain the first sample record once a calculated T statistic is greater than h value.

The code is running extremely slow and I could get only one iteration per day. I appreciate any help or suggestions anyone can provide. SAS cod eis attached.

Thank you

Attachment
Frequent Contributor
Posts: 122

Re: How do I improve performance for a slow IML based simulation code?

That is very slow indeed.  I imagine most of the time spent by your program is either processing the macro code or opening/closing proc IML.  The latter you are doing around 50 million times which must bring a significant overhead.   I think you need to rewrite the program so that all of the iterations occur within IML - no macro loops at all, use only IML do loops.

SAS Super FREQ
Posts: 3,225

Re: How do I improve performance for a slow IML based simulation code?

I agree with Ian.

Your program is currently structured like this:

%DO loops: grid in (lambda, h) space

%DO simulation loop (10,000 iterations)

   call PROC IML

   write one observation

   call PROC APPEND to append obs

%END simulation

call PROC MEANS to get mean, std, and sterr of simulation with given (lambda, h)

%END grid loops

To make it more efficient, structure it like this:

call PROC IML

CREATE output var {lambda h mean std stderr}; /* open data for results */

DO loops: grid in (lambda, h) space

DO simulation loop (10,000 iterations)

   accumulate simulated data in rows of matrix

END simulation

Use SAS/IML functions (MEAN, STD,...) to get mean/std/stderr of simulation with given (lambda, h)

APPEND;  /* write results to data set */

END grid loops

Occasional Contributor
Posts: 11

Re: How do I improve performance for a slow IML based simulation code?

Than you Ian and Rick. While I have been using SAS for over 25 years, I just started using IML a month or so ago. I will rewrite the macro within to only loop within IML. I will post my progress updates soon. Thank you again.

Post a Question
Discussion Stats
  • 3 replies
  • 494 views
  • 0 likes
  • 3 in conversation