Hi,
I have an experimental design of four way factorial among which two are random and the other two are fixed. What is the best procedure to analyze the data? Proc mixed or proc glm? And how to get the mean and interaction effect differences? I have SAS 9.4.
Thanks
From the documentation:
The MIXED procedure fits a variety of mixed linear models to data and enables you to use these fitted models to make statistical inferences about the data. A mixed linear model is a generalization of the standard linear model used in the GLM procedure, the generalization being that the data are permitted to exhibit correlation and nonconstant variability. The mixed linear model, therefore, provides you with the flexibility of modeling not only the means of your data (as in the standard linear model) but their variances and covariances as well.
Does that help you make a decision?
Thank you PaigeMiller. I understand your point. My second question was how to compare the interaction means? Because Duncan and Tukey test only give the mean effect separation but not the interactive mean separation?
Do you mean "Dunnett" instead of "Duncan"?
Both the Dunnett and Tukey tests are available for interactions in both PROC GLM and PROC MIXED in the LSMEANS statement.
If you mean DUNCAN, as far as I know it is only available in PROC GLM and only in the MEANS statement and only for main effects.
Yes, Duncan does not give the interaction mean separation.
I tried to get the interaction mean separation by LSMEANS and TUKEY but could not succeed. Could you please give me an example of SAS statement for the following example.
Four-factor design
Seasons (2 levels) random
Sites (4 levels) fixed
Depths (4 levels) random
positions (4 levels) fixed.
and we have some missing values in the data set.
Thanks, PaigeMiller again for your replies.
Show us the LOG. Click on the {i} icon and paste the log into that window. DO NOT SKIP THIS STEP. And, please explain what did not work.
Hint for future: saying "did not work" or "could not succeed" never provides enough information for a meaningful answer.
PROC MIXED DATA=RBC;
CLASS SEASON CELL TRANSECT MATERIAL;
MODEL LMBC LMBN LMBP LAPA LBISP LBGA LLAP LNAG LACDO LANCDO LPMN LPMP LNENZ LPENZ=SEASON CELL TRANSECT MATERIAL SEASON*CELL SEASON*TRANSECT SEASON*MATERIAL CELL*TRANSECT CELL*MATERIAL TRANSECT*MATERIAL SEASON*CELL*TRANSECT SEASON*CELL*MATERIAL CELL*TRANSECT*MATERIAL SEASON*TRANSECT*MATERIAL SEASON*CELL*TRANSECT*MATERIAL;
RANDOM SEASON TRANSECT SEASON*CELL SEASON*TRANSECT SEASON*MATERIAL TRANSECT*MATERIAL SEASON*CELL*TRANSECT SEASON*CELL*MATERIAL CELL*TRANSECT*MATERIAL SEASON*TRANSECT*MATERIAL SEASON*CELL*TRANSECT*MATERIAL;
LSMEANS SEASON*CELL SEASON*TRANSECT SEASON*MATERIAL CELL*TRANSECT CELL*MATERIAL TRANSECT*MATERIAL SEASON*CELL*TRANSECT SEASON*CELL*MATERIAL CELL*TRANSECT*MATERIAL SEASON*TRANSECT*MATERIAL SEASON*CELL*TRANSECT*MATERIAL/pdiff cl adjust=TUKEY;
RUN;
This one is my SAS statement. The following is the error in LOG.
547! CELL TRANSECT MATERIAL SEASON*CELL SEASON*TRANSECT SEASON*MATERIAL CELL*TRANSECT
547! CELL*MATERIAL TRANSECT*MATERIAL SEASON*CELL*TRANSECT SEASON*CELL*MATERIAL
547! CELL*TRANSECT*MATERIAL SEASON*TRANSECT*MATERIAL SEASON*CELL*TRANSECT*MATERIAL;
ERROR 73-322: Expecting an =.
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, (, *, -, /, :, @,
_CHARACTER_, _CHAR_, _NUMERIC_, |.
ERROR 200-322: The symbol is not recognized and will be ignored.
548 RANDOM SEASON TRANSECT SEASON*CELL SEASON*TRANSECT SEASON*MATERIAL TRANSECT*MATERIAL
548! SEASON*CELL*TRANSECT SEASON*CELL*MATERIAL CELL*TRANSECT*MATERIAL SEASON*TRANSECT*MATERIAL
548! SEASON*CELL*TRANSECT*MATERIAL;
549 LSMEANS SEASON*CELL SEASON*TRANSECT SEASON*MATERIAL CELL*TRANSECT CELL*MATERIAL
549! TRANSECT*MATERIAL SEASON*CELL*TRANSECT SEASON*CELL*MATERIAL CELL*TRANSECT*MATERIAL
549! SEASON*TRANSECT*MATERIAL SEASON*CELL*TRANSECT*MATERIAL/pdiff cl adjust=TUKEY;
550 RUN;
Please make your log easier to read.
Click on the {i} icon and paste the log into that window. DO NOT SKIP THIS STEP. And show us the entire log for PROC MIXED, not just where the error is.
I totally concur with @PaigeMiller 's suggestion to post the log using the "Insert Code" icon.
Meanwhile, two comments:
1. Although the GLM procedure allows multiple dependent variables in its MODEL statement, you can name only one dependent variable in the MODEL statement in the MIXED procedure. I'm pretty sure this is the source of your error, but it is not your only problem.
2. In the GLM procedure both fixed and random effects variables are specified in the MODEL statement. (However, you should never use GLM for mixed models.) In contrast, in the MIXED procedure, fixed effects variables are specified in the MODEL statement, and random effects variables are specified in the RANDOM and/or REPEATED statements. You'll want to learn more about fitting mixed models using MIXED and then revise your MODEL and RANDOM statements. For more information, see
Introduction to Mixed Modeling Procedures
SAS® for Mixed Models: Introduction and Basic Applications
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.