BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JoakimE
Obsidian | Level 7

Hi,

 

My aim to calculate the normal 95% confidence interval for specific variable 'CHG'. I know this is possible via proc univariate or via using the formula directly in proc sql. The two methods should yield identical results, but alas, they do not.

 

When I run the following code:

 

proc sql;
select
mean(CHG)+(probit(0.025)*std(CHG)/sqrt(count(CHG))) as Upper_CI,
mean(CHG)-(probit(0.025)*std(CHG)/sqrt(count(CHG))) as Lower_CI
from example_data;
quit;

 

it does not give the same result as

 

ods output BasicIntervals = work.CONFINT;
proc univariate data=example_data cibasic;
var CHG;
run;
ods output close;

 

The CIs calculated in the sql are somewhat narrower (not much, but noticeable in the second decimal for the data I've used). Can anyone shed light on what is causing the two methods to differ?

 

Any assistance would be much appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

PROC UNIVARIATE uses a t statistic, not a z score. The t statistic is the better choice, so your manual formula should use the QUANTILE function for the t distribution  and n-1 degrees of freedom:

QUANTILE("t", 1-alpha/2, n-1).

View solution in original post

2 REPLIES 2
Rick_SAS
SAS Super FREQ

PROC UNIVARIATE uses a t statistic, not a z score. The t statistic is the better choice, so your manual formula should use the QUANTILE function for the t distribution  and n-1 degrees of freedom:

QUANTILE("t", 1-alpha/2, n-1).

JoakimE
Obsidian | Level 7

Ah, yes of course! Now the two methods matches perfectly. Thanks Rick - you have increased my statistical understanding 🙂

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is ANOVA?

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.

Discussion stats
  • 2 replies
  • 590 views
  • 4 likes
  • 2 in conversation