BookmarkSubscribeRSS Feed
gorandomwalk24
Calcite | Level 5

I have data from a randomized block design with 2 treatments and 4 blocks. Each block has unequal size of subjects: only 1 subject for treatment A and a different number of subject from treatment B for each of the 4 blocks. I need to generate a graph showing the mean and error bar for each treatment group. I used the following code:

proc glm;

class trt block;

model outcome=trt block;

lsmean trt/stderr;

run;

I then use the lsmean and stderr to generate a bar graph for treatment A and B. However, it gave me a pause when I saw the stderr generated by this model for treatment A is almost 3 times higher than the raw data using proc mean (var outcome; where trt='A';), for which I only have 1 pt per block. Is my glm model correct? I think for my bar graph I should use the SE from proc means. Any insight would be greatly appreciated.    

4 REPLIES 4
SteveDenham
Jade | Level 19

Without going into how to fit an RCBD, I will take a swing at the large standard error that gets reported for treatment A. It comes down to the assumption of homogeneous variances that underlies GLM. GLM uses the pooled root mean squared error to calculate the standard errors, which may not be appropriate in a design where you treat BLOCK as a fixed effect, and the number of observations per block is unequal. Work through the first and third examples for PROC GLM in the SAS documentation. The first is for the analysis of an RCBD, the third is for an unbalanced ANOVA for a two-way design.

 

SteveDenham

gorandomwalk24
Calcite | Level 5
Thanks! I will go through the examples. An unbalanced design might be more suitable. If there are other models that may be more appropriate for my situation, please let me know.
Ksharp
Super User
I don't understand.
proc means just give you the arithmetic mean ,
while proc glm give you the adjusted least square mean.
They are totally different.
And proc means + lclm= and uclm= gave you then CI of mean .
uclm= mean + 1.96*stderr
lclm= mean - 1.96*stderr

"lsmean trt/stderr; " gave you the stderr of adjusted least square mean.They are totally different thing either .


For example:
proc glm data=sashelp.heart(obs=1000);
class sex bp_status;
model weight=sex bp_status;
lsmeans sex/stderr;
quit;

You would get:
Sex Weight_LSMEAN Stderr
Female 139.218165 0.993106
Male 165.465634 1.193024


But if you are using :
proc means data=sashelp.heart(obs=1000) mean stderr;
class sex;
var weight;
run;
You would get:
Sex Nobs Mean Stderr
Female 587 140.9368601 0.9771919
Male 413 167.5922330 1.2143178

They are totally different.



hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is ANOVA?

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.

Discussion stats
  • 4 replies
  • 413 views
  • 0 likes
  • 3 in conversation