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.
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).
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).
Ah, yes of course! Now the two methods matches perfectly. Thanks Rick - you have increased my statistical understanding 🙂
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!
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.