Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- SAS Procedures
- /
- Re: How does proc means calculate its confidence limits?

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 08-10-2020 12:16 PM
(1991 views)

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

The formulas are here:

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

The formulas are here:

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;
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

That article pertains to V6 which is around my age....

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

I like the "comparing various outputs to see what you get" approach. 🙂

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. **Registration is now open through August 30th**. Visit the SAS Hackathon homepage.

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.