Hi,
I am trying to add a tukey test to the proc mixed procedure but I can not find a way that works. I have tried adding a line "adjust=tukey" but SAS did not recognize "adjust" as a command. I also tried "lsmeans BW/tukey cldiff", but SAS did not recognize "tukey cldiff". When I say SAS does not recognize the statements I mean the text stays grey.
Here is my current code:
proc mixed data=GLANDES_TRUIE;
class TRAIT truie;
model BW=TRAIT/alpha=0.05;
repeated / group=TRAIT;
ods output tests3=tests;
lsmeans TRAIT / cl;
ods output lsmeans=lsm;
run;
This is when I add "adjust=tukey":
proc mixed data=GLANDES_TRUIE;
class TRAIT truie;
model BW=TRAIT/alpha=0.05;
repeated / group=TRAIT;
ods output tests3=tests;
lsmeans TRAIT / cl;
ods output lsmeans=lsm;
adjust=tukey;
run;
Error code:
77 adjust=tukey; ______ 180 ERROR 180-322: Statement is not valid or it is used out of proper order. 78 run; 79 80 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 90
This is when I add "lsmeans BW/tukey cldiff":
proc mixed data=GLANDES_TRUIE;
class TRAIT truie;
model BW=TRAIT/alpha=0.05;
repeated / group=TRAIT;
ods output tests3=tests;
lsmeans TRAIT / cl;
ods output lsmeans=lsm;
lsmeans BW/tukey cldiff
run;
Error Code:
77 lsmeans BW/tukey cldiff; _____ 22 202 ERROR 22-322: Syntax error, expecting one of the following: ;, ADJ, ADJDFE, ADJUST, ADJUSTMENT, ALPHA, AT, BYLEVEL, CL, CORR, COV, DF, DIFF, DIFFS, E, EST, OBSMARGINS, PDIFF, SIMPLE, SINGULAR, SLICE, TDIFF. ERROR 202-322: The option or parameter is not recognized and will be ignored. 78 run; 79
Sounds like @sbxkoenk's solution Re: Letter annotation for mean separation could be what you need: That is, add a STORE statement to the PROC MIXED step and then apply PROC PLM to the stored analysis. The LSMEANS statement of PROC PLM supports the LINES and LINESTABLE options, which do not seem to be available in PROC MIXED directly.
Hi @caroline_rg,
It's extremely useful to become familiar with the SAS documentation and the way how syntax is described there.
The syntax of the MODEL statement of PROC MIXED is
MODEL dependent = <fixed-effects> </ options>;
and the syntax of the LSMEANS statement is
LSMEANS fixed-effects </ options>;
So, assuming that your MODEL statement
model BW=TRAIT/alpha=0.05;
is correct, your second LSMEANS statement
lsmeans BW/tukey cldiff
is wrong because BW is the dependent variable (and neither TUKEY nor CLDIFF are among the options and the closing semicolon is missing).
Your first LSMEANS statement,
lsmeans TRAIT / cl;
however, makes sense and the option to request a Tukey adjustment is called ADJUST=TUKEY :
lsmeans TRAIT / cl adjust=tukey;
Hi @FreelanceReinh!
That code does work, but it doesn't do what I was hoping it would. I was looking to make a tukey table with letters assigned to significance levels. (I think it's called a tukeys honestly significant difference test?). Would this be something that can be done with proc mixed?
Sounds like @sbxkoenk's solution Re: Letter annotation for mean separation could be what you need: That is, add a STORE statement to the PROC MIXED step and then apply PROC PLM to the stored analysis. The LSMEANS statement of PROC PLM supports the LINES and LINESTABLE options, which do not seem to be available in PROC MIXED directly.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.