BookmarkSubscribeRSS Feed
souwwang
Calcite | Level 5

I used SAS 9.4 in a laptop to run some simulation studies. At beginning, the program runs very fast, just keep running and running. After the program ran for several hours, it become much slower.


For example, at beginning, it will take the program 2 hrs to finish one simulation scenario, but it may take two days to finish similar scenario some time later. I checked the log and found that SAS will stop for several minutes and do nothing after it finishes one simulation data sets, then it will continue. Any ideas about what happened, and how I can resolve it?


Thanks for the help.

3 REPLIES 3
Rick_SAS
SAS Super FREQ

We probably need more details, but my guess is that you are appending the results of each simulation. Read this article and see if it describes what you are attempting: Simulation in SAS

If that doesn't describe what you are doing, post some of your code.

souwwang
Calcite | Level 5

Thanks for the reply. I read that article, actually I used DO in my simulation codes instead of BY. Your 'BY' method is efficient, but since I need Bootstrap method to calculate 95% CI, so I cannot concatenate the data sets together and use 'BY' method, since it is too big. Actually, my problem is not code specific. When the codes generate the first several hundred simulated data set using DO loop, the program runs very fast, but as time goes on, it looks like something is stored in the memory that slows down the program. That is what I observed.

Rick_SAS
SAS Super FREQ

Great. In SAS/IML that is one way to do it if you have big data: use a DO loop for each bootstrap resample and store the statistics for each resample in an array.

However, you need to preallocate your array for the results.  It sounds like you might be using a concatenation operator inside the DO loop to dynamically increase the array.  Read this article: Pre-allocate arrays to improve efficiency - The DO Loop

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
  • 3 replies
  • 909 views
  • 0 likes
  • 2 in conversation