When I copy the example from SAS Help into the program editor both "Bayes" and "Prior" are highlighted in red as invalid. Relieved that my original coding was not inept, but concerned that SAS 's own examples produce errors. Have the Bayes options in PROC QLIM been disabled?
As always, the best way to get a helpful response is to submit the code that you are using, then copy/paste the entire log into the discussion. For example, here is what I get on my computer:
data test;
do i=1 to 200;
e1 = rannor(8726)*2000;
WinChance = ranuni(8772);
Price = 10+ranexp(8773)*4;
y = 48000 + 5000*WinChance - 100 * price + e1;
if y>50000 then TicketSales = 50000;
if y<=50000 then TicketSales = y;
output;
end;
keep WinChance price y TicketSales;
run;
proc qlim data=test plots(prior)=all;
model TicketSales = WinChance price;
endogenous TicketSales ~ censored(lb=0 ub= 50000);
prior intercept~normal(mean=48000);
prior WinChance~normal(mean=5000);
prior Price~normal(mean=-100);
bayes NBI=10000 NMC=30000 THIN=1 ntrds=1 DIAG=ALL STATS=ALL seed=2;
run;
LOG:
8695
8696 proc qlim data=test plots(prior)=all;
8697 model TicketSales = WinChance price;
8698 endogenous TicketSales ~ censored(lb=0 ub= 50000);
8699 prior intercept~normal(mean=48000);
8700 prior WinChance~normal(mean=5000);
8701 prior Price~normal(mean=-100);
8702 bayes NBI=10000 NMC=30000 THIN=1 ntrds=1 DIAG=ALL STATS=ALL seed=2;
8703 run;
NOTE: Convergence criterion (ABSGCONV=0.00001) satisfied.
NOTE: Begin simulation.
NOTE: End simulation.
NOTE: Begin calculation of summary and diagnostics statistics.
NOTE: End calculation of summary and diagnostics statistics.
NOTE: Begin plotting.
NOTE: End plotting.
NOTE: PROCEDURE QLIM used (Total process time):
real time 4.21 seconds
cpu time 2.78 seconds
Since the original question generated no interest, perhaps someone from SAS could explain why the Example they provide in the software documentation generates errors when you try to run it. Has the Bayes command been disabled for PROC QLIM?
proc qlim data=test plots(prior)=all;
model TicketSales = WinChance price;
endogenous TicketSales ~ censored(lb=0 ub= 50000);
prior intercept~normal(mean=48000);
prior WinChance~normal(mean=5000);
prior Price~normal(mean=-100);
bayes NBI=10000 NMC=30000 THIN=1 ntrds=1 DIAG=ALL STATS=ALL seed=2;
run;
Yes, the PRIOR and BAYES statements are valid in PROC QLIM.
I think you are using the old SAS 9 Enhanced Editor in the Windows environment. The color-coding in that editor is not perfect. Sometimes there are enhancements to a procedure that are not recognized by the editor's color-coding software. To determine if a statement is valid, just run the program and you will see that it works.
You are correct that the editor should not color these statements in red. I will forward your complaint to the team that supports color-coding and syntax prompting in the SAS editors.
My own code would not run as both PRIOR and BAYES were identified as errors and highlighted in red. To make sure it was an error in my code I copied the SAS example into the program editor. Same exact syntax error. I have tried this in two different computer environments and get the same error result.
The color of a statement in the editor does not prevent code from running. The BAYES and PRIOR statements were introduced in SAS/ETS 12.1, which was released as part of SAS 9.3M2. The code will run as long as you have a license for SAS/ETS and are running SAS 9.3M2 or any SAS 9.4 release. If your code does not run, you might not have a license for ETS. Run
proc setinit;run;
and examine the log. It should tell you your current version of SAS and the products that you have licensed.
Thanks for providing a way to check this possible explanation. Unfortunately, both systems have ETS in their licenses that expire no earlier than Dec. 2026.
As always, the best way to get a helpful response is to submit the code that you are using, then copy/paste the entire log into the discussion. For example, here is what I get on my computer:
data test;
do i=1 to 200;
e1 = rannor(8726)*2000;
WinChance = ranuni(8772);
Price = 10+ranexp(8773)*4;
y = 48000 + 5000*WinChance - 100 * price + e1;
if y>50000 then TicketSales = 50000;
if y<=50000 then TicketSales = y;
output;
end;
keep WinChance price y TicketSales;
run;
proc qlim data=test plots(prior)=all;
model TicketSales = WinChance price;
endogenous TicketSales ~ censored(lb=0 ub= 50000);
prior intercept~normal(mean=48000);
prior WinChance~normal(mean=5000);
prior Price~normal(mean=-100);
bayes NBI=10000 NMC=30000 THIN=1 ntrds=1 DIAG=ALL STATS=ALL seed=2;
run;
LOG:
8695
8696 proc qlim data=test plots(prior)=all;
8697 model TicketSales = WinChance price;
8698 endogenous TicketSales ~ censored(lb=0 ub= 50000);
8699 prior intercept~normal(mean=48000);
8700 prior WinChance~normal(mean=5000);
8701 prior Price~normal(mean=-100);
8702 bayes NBI=10000 NMC=30000 THIN=1 ntrds=1 DIAG=ALL STATS=ALL seed=2;
8703 run;
NOTE: Convergence criterion (ABSGCONV=0.00001) satisfied.
NOTE: Begin simulation.
NOTE: End simulation.
NOTE: Begin calculation of summary and diagnostics statistics.
NOTE: End calculation of summary and diagnostics statistics.
NOTE: Begin plotting.
NOTE: End plotting.
NOTE: PROCEDURE QLIM used (Total process time):
real time 4.21 seconds
cpu time 2.78 seconds
I can not share my code as it is within a confidential data center. However, running the test example for PROC QLIM first seemed to convince SAS it could also run my original code that it had earlier aborted because of errors. Not sure if this increases or lessens my confidence in SAS.
If you had been able to share your original program and log, I feel confident that it would have revealed a problem in the initial submission. It could have been a missing or misspecified data set, a missing semicolon, a missing RUN statement, or something else. Anyway, I'm glad you were able to resolve the issue.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.