BookmarkSubscribeRSS Feed
Tidemann2nd
Calcite | Level 5

I am using the LSMestimate statement in glimmix to compare groups of my treatments that have similarities.  I.e. treatments 1, 3 and 5 were applied early while treatments 2, 4 and 6 were applied late.  I've figured out how to write the LSMestimate statement to run the comparison (I think).  I get an estimate, a standard error, a p-value, etc.  And I have the LSmeans for the different individual treatments.  Is there any way to get an LSmeans for say the early application group (trts 1, 3 and 5) and the late application group (trts 2, 4 and 6)? This may be a ridiculous question but all my notes are in my office (not allowed back to work yet) and I can't seem to articulate quite what I'm trying to search for to just google it.  Any help would be appreciated!!  

 

(This is a simplified version of what I'm doing which is why I haven't included any code, but I can expand and include my actual code if needed).

 

Thank you!

5 REPLIES 5
ballardw
Super User

I never hurts to show the code you are attempting.

 

The first thing I would try is to make a custom format for the values of the variable that you want to group and then apply the format to the variable in the model code. Most of the procedures will honor groups created by formats.

Maybe something like

 

Proc format;

 value trtgroup

1,3,5 ='Group 1'

2,4,6 ='Group 2'

;

run;

 

and then add a statement like:

format trt trtgroup. ;

to the procedure.

If your values are character the format name needs to start with a $ and use that in the format statement and the values should be quoted in the Value statement: '1', '3', '5' ='Group 1'.

SteveDenham
Jade | Level 19

We do this on a regular basis using the LSMESTIMATE statement. If the variable of interest in the model is called treatment, then the following code would be usable:

 

lsmestimate treatment 'Early application' 1 0 1 0 1 0,
                      'Late application ' 0 1 0 1 0 1/divisor=3;

This assumes equal weighting for each of the groups. The issue with using the format approach is that you would need a separate model with the formatted data to get the least squares means (I think).

 

SteveDenham

 

Tidemann2nd
Calcite | Level 5

What would the difference be between that code and

 

lsmestimate treatment "early vs late" 1 -1 1 -1 1 -1;

 

Is one a comparison and one asking for estimates of the respective groups? Or am I out to lunch?

SteveDenham
Jade | Level 19

@Tidemann2nd , you nailed it.  Your code is the difference between the two group estimates.

 

SteveDenham

Tidemann2nd
Calcite | Level 5
Thank you!!! Between our two codes I can get the estimates for the groups and test for differences between them which is exactly what I needed. Thank you so much for your help!!



Breanne


sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

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
  • 5 replies
  • 1146 views
  • 2 likes
  • 3 in conversation