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

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
Reeza
Super User

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;


View solution in original post

5 REPLIES 5
Reeza
Super User

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;


Cynthia_sas
SAS Super FREQ

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

Reeza
Super User
That article pertains to V6 which is around my age....
Nicole_Fox
Obsidian | Level 7
I like the "comparing various outputs to see what you get" approach. 🙂

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1833 views
  • 10 likes
  • 4 in conversation