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
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.
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
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.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.