Hello,
I'm trying to fit a model using PROC MCMC and output credible intervals for each parameter. I add the option ods output PostSumInt = intervals, which should output by default. Below is the code I've specified for fitting the model.
ods output Corr = mycorr
Cov = mycov
DIC = mydic
PostSummaries = myparams
Geweke = mygeweke
PostSumInt = intervals; * output ods tables of interest to datasets;
PROC MCMC
data = data SEED=9879 NMC=100000 NBI=500 MAXTUNE=50 THIN=25 STATISTICS = summary DIAGNOSTICS = GEWEKE STATS = CORR STATS = COV DIC;
ARRAY location_scale_mean[2] (0,0);
ARRAY location_scale_cov[2,2] (1,0,0,1);
ARRAY location_scale_rf[2] sub_1 sub_2;
PARMS b0=0.02 b1=0.22 b2=-0.07 b3=0.21 b4=0.13
tau0=0.17 tau1=0.11 tau2=0.13 tau3=0.21 tau4=-0.15
lp0=0.25 lp1=0.12 lp2=-1.08
cov=-0.09 ln_varScale=0.33;
BY rep_n;
WHERE rep_n < 4;
PRIOR b: ~NORMAL (0, VAR=1000);
PRIOR tau: ~NORMAL (0, VAR=1000);
PRIOR lp: ~NORMAL (0, VAR=1000);
PRIOR cov: ~NORMAL (0, VAR=1000);
PRIOR ln_varScale~NORMAL(0,VAR=1000);
varBS = EXP(lp0 + W1_c*lp1 + W2_b*lp2);
varScale = EXP(ln_varScale);
L11=SQRT(varBS);
L21=cov/L11;
L22=SQRT(varScale-L21**2);
mu = b0 + b1*X1_c + b2*X2_b + b3*W1_c + b4*W2_b + L11*sub_1;
varWS = EXP(tau0 + X1_c*tau1 + X2_b*tau2 + W1_c*tau3 + W2_b*tau4 + L21*sub_1 + L22*sub_2);
RANDOM location_scale_rf ~ mvn(location_scale_mean,location_scale_cov) SUBJECT=subj;
MODEL y ~ NORMAL(mu,var = varWS);
RUN;
ods output close;
After running this model, I get an error message that says:
1. Can you please post the full log?
2. What version of SAS/STAT do you have? You can verify that with:
proc product_status;run;
@mcraft wrote:
Hello,
I'm trying to fit a model using PROC MCMC and output credible intervals for each parameter. I add the option ods output PostSumInt = intervals, which should output by default. Below is the code I've specified for fitting the model.
ods output Corr = mycorr
Cov = mycov
DIC = mydic
PostSummaries = myparams
Geweke = mygeweke
PostSumInt = intervals; * output ods tables of interest to datasets;
PROC MCMC
data = data SEED=9879 NMC=100000 NBI=500 MAXTUNE=50 THIN=25 STATISTICS = summary DIAGNOSTICS = GEWEKE STATS = CORR STATS = COV DIC;ARRAY location_scale_mean[2] (0,0);
ARRAY location_scale_cov[2,2] (1,0,0,1);
ARRAY location_scale_rf[2] sub_1 sub_2;PARMS b0=0.02 b1=0.22 b2=-0.07 b3=0.21 b4=0.13
tau0=0.17 tau1=0.11 tau2=0.13 tau3=0.21 tau4=-0.15
lp0=0.25 lp1=0.12 lp2=-1.08
cov=-0.09 ln_varScale=0.33;BY rep_n;
WHERE rep_n < 4;PRIOR b: ~NORMAL (0, VAR=1000);
PRIOR tau: ~NORMAL (0, VAR=1000);
PRIOR lp: ~NORMAL (0, VAR=1000);
PRIOR cov: ~NORMAL (0, VAR=1000);
PRIOR ln_varScale~NORMAL(0,VAR=1000);varBS = EXP(lp0 + W1_c*lp1 + W2_b*lp2);
varScale = EXP(ln_varScale);L11=SQRT(varBS);
L21=cov/L11;
L22=SQRT(varScale-L21**2);mu = b0 + b1*X1_c + b2*X2_b + b3*W1_c + b4*W2_b + L11*sub_1;
varWS = EXP(tau0 + X1_c*tau1 + X2_b*tau2 + W1_c*tau3 + W2_b*tau4 + L21*sub_1 + L22*sub_2);RANDOM location_scale_rf ~ mvn(location_scale_mean,location_scale_cov) SUBJECT=subj;
MODEL y ~ NORMAL(mu,var = varWS);RUN;
ods output close;
After running this model, I get an error message that says:
WARNING: Output 'PostSumInt' was not created. Make sure that the output object name, label, or path is spelled correctly. Also,verify that the appropriate procedure options are used to produce the requested output object. For example, verify thatthe NOPRINT option is not used.Any ideas on why this output was not created? I'm pretty sure it's spelled correctly and I can't find any required options for producing this output.Thanks!Madeline
1.
1 libname s10_100 "C:/Users/mcraft/Desktop/PROC MCMC Simulations/data10_100/output";
NOTE: Libref S10_100 was successfully assigned as follows:
Engine: V9
Physical Name: C:\Users\mcraft\Desktop\PROC MCMC Simulations\data10_100\output
2 ods graphics off; * suppress ods graphics for a more efficient simulation;
3 ods exclude all; * suppress ods output for a more efficient simulation;
4 ods output Corr = s10_100.mycorr
NOTE: Writing HTML Body file: sashtml.htm
5 Cov = s10_100.mycov
6 DIC = s10_100.mydic
7 PostSummaries = s10_100.myparams
8 Geweke = s10_100.mygeweke
9 PostSumInt = s10_100.intervals; * output ods tables of interest to datasets;
10 PROC MCMC
11 data = s10_100.data SEED=9879 NMC=100000 NBI=500 MAXTUNE=50 THIN=25 STATISTICS = summary
11 ! DIAGNOSTICS = GEWEKE STATS = CORR STATS = COV DIC;
12 *data = s10_100.data SEED=9879 NMC=100000 NBI=500 MAXTUNE=50 THIN=25 NTHREADS=4 DIAGNOSTICS =
12 ! AUTOCORR PROPCOV = method(ITPRINT) STATS = CORR STATS = COV DIC;
13
14 ARRAY location_scale_mean[2] (0,0);
15 ARRAY location_scale_cov[2,2] (1,0,0,1);
16 ARRAY location_scale_rf[2] sub_1 sub_2;
17
18 PARMS b0=0.02 b1=0.22 b2=-0.07 b3=0.21 b4=0.13
19 tau0=0.17 tau1=0.11 tau2=0.13 tau3=0.21 tau4=-0.15
20 lp0=0.25 lp1=0.12 lp2=-1.08
21 cov=-0.09 ln_varScale=0.33;
22
23 BY rep_n;
24 WHERE rep_n = 1;
25
26 PRIOR b: ~NORMAL (0, VAR=1000);
27 PRIOR tau: ~NORMAL (0, VAR=1000);
28 PRIOR lp: ~NORMAL (0, VAR=1000);
29 PRIOR cov: ~NORMAL (0, VAR=1000);
30 PRIOR ln_varScale~NORMAL(0,VAR=1000);
31
32 varBS = EXP(lp0 + W1_c*lp1 + W2_b*lp2);
33 varScale = EXP(ln_varScale);
34
35 L11=SQRT(varBS);
36 L21=cov/L11;
37 L22=SQRT(varScale-L21**2);
38
39 mu = b0 + b1*X1_c + b2*X2_b + b3*W1_c + b4*W2_b + L11*sub_1;
40 varWS = EXP(tau0 + X1_c*tau1 + X2_b*tau2 + W1_c*tau3 + W2_b*tau4 + L21*sub_1 + L22*sub_2);
41
42 RANDOM location_scale_rf ~ mvn(location_scale_mean,location_scale_cov) SUBJECT=subj;
43 MODEL y ~ NORMAL(mu,var = varWS);
44
45 RUN;
NOTE: Tuning the proposal distribution.
NOTE: Generating the burn-in samples.
NOTE: Beginning sample generation.
NOTE: The above message was for the following BY group:
rep_n=1
NOTE: The data set S10_100.MYGEWEKE has 15 observations and 4 variables.
NOTE: The data set S10_100.MYPARAMS has 15 observations and 8 variables.
NOTE: The data set S10_100.MYDIC has 4 observations and 3 variables.
NOTE: The data set S10_100.MYCOV has 15 observations and 17 variables.
NOTE: The data set S10_100.MYCORR has 15 observations and 17 variables.
WARNING: Output 'PostSumInt' was not created. Make sure that the output object name, label, or path
is spelled correctly. Also, verify that the appropriate procedure options are used to
produce the requested output object. For example, verify that the NOPRINT option is not
used.
NOTE: PROCEDURE MCMC used (Total process time):
real time 1:28.96
cpu time 1:28.48
46 ods output close;
47 ods exclude none;
2.
48 proc product_status;run;
For Base SAS Software ...
Custom version information: 9.4
Image version information: 9.04.01M0P061913
For SAS/STAT ...
Custom version information: 12.3 (maintenance)
For SAS/GRAPH ...
Custom version information: 9.4
For SAS/ETS ...
Custom version information: 12.3 (maintenance)
For SAS/FSP ...
Custom version information: 9.4
For SAS/OR ...
Custom version information: 12.3 (maintenance)
For SAS/AF ...
Custom version information: 9.4
For SAS/IML ...
Custom version information: 12.3 (maintenance)
For SAS/QC ...
Custom version information: 12.3 (maintenance)
For SAS/SHARE ...
Custom version information: 9.4
For SAS/ASSIST ...
Custom version information: 9.4
For SAS/CONNECT ...
Custom version information: 9.4
For SAS/TOOLKIT ...
Custom version information: 9.4
For SAS/EIS ...
Custom version information: 9.4
For SAS/GIS ...
Custom version information: 9.4
For SAS/ACCESS Interface to Netezza ...
Custom version information: 9.4
For SAS Enterprise Miner ...
Custom version information: 12.3
For SAS/ACCESS to Vertica ...
Custom version information: 9.4
For SAS/ACCESS to Postgres ...
Custom version information: 9.4
For SAS/IntrNet ...
Custom version information: 9.4
For SAS Integration Technologies ...
Custom version information: 9.4
For SAS Text Miner ...
Custom version information: 12.3
For SAS/ACCESS to SAP HANA ...
Custom version information: 9.4
Image version information: 9.04.01M0P071013
For SAS/Genetics ...
Custom version information: 9.4
For SAS/ACCESS Interface to DB2 ...
Custom version information: 9.4
For SAS/ACCESS Interface to Oracle ...
Custom version information: 9.4
For SAS/ACCESS Interface to Sybase ...
Custom version information: 9.4
For SAS/ACCESS Interface to PC Files ...
Custom version information: 9.4
For SAS/ACCESS Interface to ODBC ...
Custom version information: 9.4
For SAS/ACCESS Interface to OLE DB ...
Custom version information: 9.4
For SAS/ACCESS Interface to Teradata ...
Custom version information: 9.4
For SAS/ACCESS Interface to MySQL ...
Custom version information: 9.4
Thank you so much! I will see if I can get it updated.
I have a follow-up issue. I'm now using the ODS Table Name PostIntervals since this option outputs credible intervals for 12.3. Below is my model code, but I'm still getting an error message (see below).
ods graphics off; * suppress ods graphics for a more efficient simulation;
ods exclude all; * suppress ods output for a more efficient simulation;
ods output Corr = s10_100.mycorr
Cov = s10_100.mycov
DIC = s10_100.mydic
PostSummaries = s10_100.myparams
Geweke = s10_100.mygeweke
PostIntervals = s10_100.intervals; * output ods tables of interest to datasets;
PROC MCMC
data = s10_100.data SEED=9879 NMC=100000 NBI=500 MAXTUNE=50 THIN=25 STATISTICS = summary DIAGNOSTICS = GEWEKE STATS = CORR STATS = COV DIC;
*data = s10_100.data SEED=9879 NMC=100000 NBI=500 MAXTUNE=50 THIN=25 NTHREADS=4 DIAGNOSTICS = AUTOCORR PROPCOV = method(ITPRINT) STATS = CORR STATS = COV DIC;
ARRAY location_scale_mean[2] (0,0);
ARRAY location_scale_cov[2,2] (1,0,0,1);
ARRAY location_scale_rf[2] sub_1 sub_2;
PARMS b0=0.02 b1=0.22 b2=-0.07 b3=0.21 b4=0.13
tau0=0.17 tau1=0.11 tau2=0.13 tau3=0.21 tau4=-0.15
lp0=0.25 lp1=0.12 lp2=-1.08
cov=-0.09 ln_varScale=0.33;
BY rep_n;
WHERE rep_n < 4;
PRIOR b: ~NORMAL (0, VAR=1000);
PRIOR tau: ~NORMAL (0, VAR=1000);
PRIOR lp: ~NORMAL (0, VAR=1000);
PRIOR cov: ~NORMAL (0, VAR=1000);
PRIOR ln_varScale~NORMAL(0,VAR=1000);
varBS = EXP(lp0 + W1_c*lp1 + W2_b*lp2);
varScale = EXP(ln_varScale);
L11=SQRT(varBS);
L21=cov/L11;
L22=SQRT(varScale-L21**2);
mu = b0 + b1*X1_c + b2*X2_b + b3*W1_c + b4*W2_b + L11*sub_1;
varWS = EXP(tau0 + X1_c*tau1 + X2_b*tau2 + W1_c*tau3 + W2_b*tau4 + L21*sub_1 + L22*sub_2);
RANDOM location_scale_rf ~ mvn(location_scale_mean,location_scale_cov) SUBJECT=subj;
MODEL y ~ NORMAL(mu,var = varWS);
RUN;
ods output close;
ods exclude none;
NOTE: Tuning the proposal distribution.
NOTE: Generating the burn-in samples.
NOTE: Beginning sample generation.
NOTE: The above message was for the following BY group:
rep_n=1
NOTE: Tuning the proposal distribution.
NOTE: Generating the burn-in samples.
NOTE: Beginning sample generation.
NOTE: The above message was for the following BY group:
rep_n=2
NOTE: Tuning the proposal distribution.
NOTE: Generating the burn-in samples.
NOTE: Beginning sample generation.
NOTE: The above message was for the following BY group:
rep_n=3
NOTE: The data set S10_100.MYGEWEKE has 45 observations and 4 variables.
NOTE: The data set S10_100.MYPARAMS has 45 observations and 8 variables.
NOTE: The data set S10_100.MYDIC has 12 observations and 3 variables.
NOTE: The data set S10_100.MYCOV has 45 observations and 17 variables.
NOTE: The data set S10_100.MYCORR has 45 observations and 17 variables.
WARNING: Output 'PostIntervals' was not created. Make sure that the output object name, label, or
path is spelled correctly. Also, verify that the appropriate procedure options are used to
produce the requested output object. For example, verify that the NOPRINT option is not
used.
NOTE: PROCEDURE MCMC used (Total process time):
real time 4:24.27
cpu time 4:23.96
If I were to use SAS on Demand, the PostSumInt option should work because it'll be the most up-to-date version of SAS, right?
I ask because I'm getting the same error message using SAS on Demand, which makes me wonder whether the issue is broader than just the SAS version I'm working with.
Thank you for all of your help!
PostSumInt works fine on On Demand for me - example from documentation was used.
/*-----------------------------------------------------------------
S A S S A M P L E L I B R A R Y
NAME: MCMCEX4
TITLE: Documentation Example 4 for PROC MCMC
Logistic Regression Model with Jeffreys' Prior
PRODUCT: STAT
SYSTEM: ALL
KEYS:
PROCS: MCMC
DATA:
SUPPORT: Fang Chen
REF: PROC MCMC, EXAMPLE 4
MISC:
-----------------------------------------------------------------*/
title 'Logistic Regression Model with Jeffreys Prior';
data vaso;
input vol rate resp @@;
lvol = log(vol);
lrate = log(rate);
ind = _n_;
cnst = 1;
datalines;
3.7 0.825 1 3.5 1.09 1 1.25 2.5 1 0.75 1.5 1
0.8 3.2 1 0.7 3.5 1 0.6 0.75 0 1.1 1.7 0
0.9 0.75 0 0.9 0.45 0 0.8 0.57 0 0.55 2.75 0
0.6 3.0 0 1.4 2.33 1 0.75 3.75 1 2.3 1.64 1
3.2 1.6 1 0.85 1.415 1 1.7 1.06 0 1.8 1.8 1
0.4 2.0 0 0.95 1.36 0 1.35 1.35 0 1.5 1.36 0
1.6 1.78 1 0.6 1.5 0 1.8 1.5 1 0.95 1.9 0
1.9 0.95 1 1.6 0.4 0 2.7 0.75 1 2.35 0.03 0
1.1 1.83 0 1.1 2.2 1 1.2 2.0 1 0.8 3.33 1
0.95 1.9 0 0.75 1.9 0 1.3 1.625 1
;
%let n = 39;
proc mcmc data=vaso nmc=10000 outpost=mcmcout seed=17;
ods output PostSumInt = want;
array beta[3] beta0 beta1 beta2;
array m[&n, &n];
array x[1] / nosymbols;
array xt[3, &n];
array xtm[3, &n];
array xmx[3, 3];
array p[&n];
parms beta0 1 beta1 1 beta2 1;
begincnst;
if (ind eq 1) then do;
rc = read_array("vaso", x, "cnst", "lvol", "lrate");
call transpose(x, xt);
call zeromatrix(m);
end;
endcnst;
beginnodata;
call mult(x, beta, p); /* p = x * beta */
do i = 1 to &n;
p[i] = 1 / (1 + exp(-p[i])); /* p[i] = 1/(1+exp(-x*beta)) */
m[i,i] = p[i] * (1-p[i]);
end;
call mult (xt, m, xtm); /* xtm = xt * m */
call mult (xtm, x, xmx); /* xmx = xtm * x */
call det (xmx, lp); /* lp = det(xmx) */
lp = 0.5 * log(lp); /* lp = -0.5 * log(lp) */
prior beta: ~ general(lp);
endnodata;
model resp ~ bern(p[ind]);
run;
Log:
NOTE: The input data set variable ind appears in the distributional specification for beta0. This might lead to incorrect results. NOTE: Tuning the proposal distribution. NOTE: Generating the burn-in samples. NOTE: Beginning sample generation. NOTE: Generating diagnostic plots. NOTE: The data set WORK.WANT has 3 observations and 6 variables. NOTE: The data set WORK.MCMCOUT has 10000 observations and 7 variables. NOTE: PROCEDURE MCMC used (Total process time): real time 1.13 seconds user cpu time 0.71 seconds system cpu time 0.08 seconds memory 24393.70k OS Memory 51800.00k Timestamp 12/02/2021 12:36:09 AM Step Count 114 Switch Count 41 Page Faults 0 Page Reclaims 11234 Page Swaps 0 Voluntary Context Switches 761 Involuntary Context Switches 1 Block Input Operations 0 Block Output Operations 17288
@mcraft wrote:
If I were to use SAS on Demand, the PostSumInt option should work because it'll be the most up-to-date version of SAS, right?
I ask because I'm getting the same error message using SAS on Demand, which makes me wonder whether the issue is broader than just the SAS version I'm working with.
Thank you for all of your help!
If you're having further issues it could be related to your data or something else. If you have a licensed version of SAS I'd call Tech Support at this point.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.