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!
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'.
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
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?
@Tidemann2nd , you nailed it. Your code is the difference between the two group estimates.
SteveDenham
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.
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.