Fluorite | Level 6

## How does proc means calculate its confidence limits?

Hello all,

I am working on graphing my proc means data points but the confidence limits that my proc means is calculating doesn't seem to be right according to my calculations?

I am calculating the confidence limit as MEAN +/- 1.96*Standard Error.

If someone could elucidate how SAS calculates the "LCLM" and "UCLM" and how it is different from my calculation, that would be much appreciated.

``````proc means data=wide_merged_file_sans_pooled n mean stddev stderr lclm uclm median min max STACKODS;
var itac_fuvisit_f0 itac_fuvisit_f1 itac_fuvisit_f2 itac_fuvisit_f3 itac_fuvisit_f5
itac_fuvisit_f6 itac_fuvisit_f7 itac_fuvisit_f8;
ods output summary = summaryStats; run;``````
1 ACCEPTED SOLUTION

Accepted Solutions
Super User

## Re: How does proc means calculate its confidence limits?

The formulas are here:

https://documentation.sas.com/?docsetId=proc&docsetTarget=p0v0y1on1hbxukn0zqgsp5ky8hc0.htm&docsetVer...

SAS uses the t-distribution, not normal so it varies very slightly based on the number of observations. If you only have a few observations you'll see differences from the z-score calculations.

Here's an example that illustrates the issue. I would have expected it to be closer as well.

``````proc means data=sashelp.class N MEAN STDDEV STDERR UCLM LCLM alpha=0.05 STACKODS;
var weight height;
ods output summary = summaryStats;
run;

data check_calcs;
set summaryStats;

*19 for the number of observations;
p=quantile('T', .975, 19);

manual_UCLM = mean + p*stderr;
manual_LCLM = mean - p*stderr;

diff_UCLM = UCLM - manual_UCLM;
diff_LCLM = LCLM - manual_LCLM;

format diff: 8.4;
run;

proc print data=check_calcs;
run;

``````
5 REPLIES 5
Super User

## Re: How does proc means calculate its confidence limits?

The formulas are here:

https://documentation.sas.com/?docsetId=proc&docsetTarget=p0v0y1on1hbxukn0zqgsp5ky8hc0.htm&docsetVer...

SAS uses the t-distribution, not normal so it varies very slightly based on the number of observations. If you only have a few observations you'll see differences from the z-score calculations.

Here's an example that illustrates the issue. I would have expected it to be closer as well.

``````proc means data=sashelp.class N MEAN STDDEV STDERR UCLM LCLM alpha=0.05 STACKODS;
var weight height;
ods output summary = summaryStats;
run;

data check_calcs;
set summaryStats;

*19 for the number of observations;
p=quantile('T', .975, 19);

manual_UCLM = mean + p*stderr;
manual_LCLM = mean - p*stderr;

diff_UCLM = UCLM - manual_UCLM;
diff_LCLM = LCLM - manual_LCLM;

format diff: 8.4;
run;

proc print data=check_calcs;
run;

``````
SAS Super FREQ

## Re: How does proc means calculate its confidence limits?

HI:
Suggest you refer to the PROC MEANS doc: https://go.documentation.sas.com/?docsetId=proc&docsetTarget=n1qnc9bddfvhzqn105kqitnf29cp.htm&docset... you can control the ALPHA using the ALPHA= option. The default ALPHA is .05, giving a confidence limit of 95%.

The doc says:
" ALPHA=value ... specifies the confidence level to compute the confidence limits for the mean. The percentage for the confidence limits is (1−value)×100. An example is (ALPHA=.05 results in a 95% confidence limit)."

Cynthia

Obsidian | Level 7

## Re: How does proc means calculate its confidence limits?

You might also find this older article helpful: Confidence in the 95% Confidence Interval of Mean

Super User

## Re: How does proc means calculate its confidence limits?

That article pertains to V6 which is around my age....
Obsidian | Level 7

## Re: How does proc means calculate its confidence limits?

I like the "comparing various outputs to see what you get" approach. 🙂
Discussion stats
• 5 replies
• 2042 views
• 10 likes
• 4 in conversation