03-14-2017 11:37 AM
I’m using SAS 9.2 TS2M3 IML.
I’m running some simulations and get the following error after some repetitions.
ERROR: Out of memory for symbols. Cannot proceed.
If I decrease the number of repetitions this does not happen.
Do you know what I can try to do about it?
It is a program containing 8 macros.
Thankful for any help I can get.
03-14-2017 01:58 PM
There are a couple of system options that control the the number of macro variables and macros.
MSYMTABMAX control the overall memory available to the symbol table.
You may need to increase the default value.
You can find your current value with:
proc options group=macro;run;
Options msymtabmax = n (or nK or nM or nG);
I might suggest
options msymtabmax=16m; to set 16 megabytes which might be about 4 times your default.
If you keep running into this limit it is often a symptom of sub-optimal macro coding.
Related settings to investigate may be MEXECSIZE adn MVARSIZE.
03-14-2017 02:08 PM
Well, I'm confused because usually the number of symbols in a simulation does not depend on the number of iterations. If you have a loop like
DO i = 1 to 10000;
/* simulate data for the i_th sample */
then the number of symbols is the same whether you loop 100, 10000. or 1E6 times.
My guess, then, is that you are doing something nonstandard (and potentially inefficient) like manufacturing names of symbols that depend on the iteration number. Can you attach your program?
03-16-2017 10:03 AM
Yes Rick you are right, I am using the iteration number to create some variables.
I have attatched my program. Im thinking maybe its best if I rewrite my program and avoiding using the iteration numbers for creating variables.
I tried changing the number of macro variables and macros as ballardw suggested.
Also tried to increace symsize and worksize to 150.000 I think without success.
In my program, the problem occurs when im increasing P (number of variables in the simulated data set) to 20, 50, 100.
Then I am not allowed to to many replicates (R) at all. For P=20 I have managed to do 500 replicates. For P=50 I have manage to do 50 replicates.
03-16-2017 10:33 AM
I don't know what you are trying to do, but SAS/IML has a DO loop, so in most situations you do not need to to use a %DO macro loop.
A few comments:
1. It looks like you might be trying to generate K covariance matrices in the first DO loop, and then you want to be able to refer back to them later in the program. If that is the case, you might just want to store the covariance matrices as rows in matrix that has K rows and P*P columns, as shown in the article "Create an array of matrices." (Or, since the matrices are symmetric, you can just store the upper triangular portion.)
2. Consider replacing those macros with SAS/IML functions calls. The SAS/IML language enables you to write self-contained user-defined functions called modules. The modules will be easier to write, debug, and maintain than macro code.
3. Learn about the built-in functions in SAS/IML that generate multivariate distributions. It looks like the C matrices are supposed to be a random sample from the Wishart distribution with N-1 degrees of freedom. You can generate those matrices with a single call to the RANDWISHART function, and they will be pre-packed into a matrix, as I suggested in my first comment.