BookmarkSubscribeRSS Feed
Anita_n
Pyrite | Level 9

Dear all,

I have a graph showing the mean ages in different diagnosis years. I wish to add standard errors to this plot. Is it right to do that with proc means like below and then deduct or add these values from/to the maen ages to get the upper and lower limits. Or do I say lower= mean_age- 2*stderr ,

and upper= mean_age+2*stderr. Why is this standard error important?

proc means data=mydata noprint;
var age;
class year sex;
output out = myoutdat mean=mean_age stderr=stderr ;
run;

 

5 REPLIES 5
Ksharp
Super User
proc means data=sashelp.class noprint;
var age;
class sex;
output out = myoutdat mean=mean_age stderr=stderr ;
run;

data myoutdat;
set myoutdat;
lower= mean_age- 2*stderr ;
higher= mean_age+ 2*stderr ;
run;
proc sgplot data=myoutdat;
scatter x=sex y=mean_age/yerrorlower=lower yerrorupper=higher;
run;
Anita_n
Pyrite | Level 9

Thanks, I just wanted to know which solution is better, is it better using the LCLM  and UCLM  in proc means or using mean_age +/- 2*stderr to get the confident intervals

ballardw
Super User

@Anita_n wrote:

Thanks, I just wanted to know which solution is better, is it better using the LCLM  and UCLM  in proc means or using mean_age +/- 2*stderr to get the confident intervals


Compare the two values for some data. See which makes sense for your purpose. There's also CLM that you could add/subtract from the mean to get a limit to display.

 

Sometimes one of the limits may not make sense and needs to be censored. For instance if your data relates to patient weight and you get a LCLM of -5 (pounds or kilograms) does that make sense? A weight for a person in the negative range is highly problematic (and likely would come from data with extreme values, small sample and possibly a mix of adults and children).

So "best" comes from "know your data" and making decisions to show the story you intend.

 

 

Anita_n
Pyrite | Level 9

@ballardw yes, you are right I compared the values and realised they are very similar, there just very very small differences. In my case there were no negative values for the mean ages. I think I will just choose one of the methods

Ksharp
Super User
I would prefer to " LCLM and UCLM ".

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1450 views
  • 2 likes
  • 3 in conversation