05-05-2017 01:39 PM - edited 05-05-2017 01:44 PM
Trying to run this code in SAS 94 windows environment. It takes much time in SAS 9.4 compared with SAS 9.2. Any suggestions on how to improve the performance?
ods _all_ close; ods preferences; data heights; input Family G$ Height @@; datalines; 1 F 67 1 F 66 1 F 64 1 M 71 1 M 72 2 F 63 2 F 63 2 F 67 2 M 69 2 M 68 2 M 70 3 F 63 3 M 64 4 F 67 4 F 66 4 M 67 4 M 67 4 M 69 ; run; data input; set heights; if g eq 'F' then gf = 1; else gf = 0; drop g; if family=1 then do; indf1=1; indf2=0; indf3=0; indf4=0; end; else if family=2 then do; indf1=0; indf2=1; indf3=0; indf4=0; end; else if family=3 then do; indf1=0; indf2=0; indf3=1; indf4=0; end; else if family=4 then do; indf1=0; indf2=0; indf3=0; indf4=1; end; run; ods graphics on; proc mcmc data=input outpost=postout nmc=50000 seed=7893 plots= (trace density) diag=none monitor=(b0 b1) STATISTICS=summary statistics=interval; ods select postsummaries postintervals tdpanel;; parms b0 0 b1 0 s2 1 s2g 1; prior b: ~ normal(0, var = 10000); prior s: ~ igamma(0.01, scale = 0.01); random gamma ~ normal(0, var = s2g) subject=family monitor=(gamma); mu = b0 + b1 * gf + gamma; model height ~ normal(mu, var = s2); ods output postintervals=pint postsummaries=psum; run; quit; ods graphics off; proc print data=pint; run; proc print data=psum; run; ;
05-05-2017 01:44 PM
I don't know about the rest of your code but you can simplify the if/then section:
array indf(4) indf1-indf4 (4*0); *initialize all to 0 to start with; indf(family) = 1;
05-05-2017 01:51 PM
Ok, can I assume then you've diagnosed the performance problem/bottleneck as being in PROC MCMC?
If so, how long is it currently taking and how long did it take before?
Also, in the upgrade from 9.2 to 9.4 did anything else change?
05-05-2017 02:05 PM
There is almost a 15 seconds delay for the same program between 92 and 94. The time will increase a lot if I run with many simulations. I beleive part of the problem is with ods graphics. I heard that a lot has been changed in ods graphics between 92 and 94
05-05-2017 02:15 PM
Yes, ODS Graphics are enhanced, and creating graphs is where it seems to lag. Given your specifications I assume you want a graph though.
Have you tried turning off 'show results as generated' option? That may also speed it up, since it writes it but isn't taking the time to try and display it.
05-05-2017 05:49 PM
This wasn't under Statistical Procedures, so I've moved it there to hopefully get a better response.
SAS is always interested in when things change between versions, so tech support is probably a good next place to get help, if you haven't already. 9.2 to 9.4 is a big jump though...it's much easier to work with in a lot of ways.
05-06-2017 05:53 AM
1. This program takes about 2 seconds for me to run, so I am not seeing the performance problem you see. Most of that 2 seconds is creating output.
2. In the first line of your program, you close all the ODS destinations. This is usually a bad idea. Between 9.2 and 9.3, one of the biggest changes is that HTML became the default destination, instead of LISTING. HTML is a more complex destination and is slower than LISTING. For an apples-to-apples comparison, delete the first line and replace it with
ODS HTML CLOSE;
3. To learn why ODS _ALL_ CLOSE is a bad idea, see "Five reasons to use ODS EXCLUDE to suppress output"