BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
caroline_rg
Fluorite | Level 6

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     

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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.

View solution in original post

4 REPLIES 4
FreelanceReinh
Jade | Level 19

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;

 

caroline_rg
Fluorite | Level 6

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?

FreelanceReinh
Jade | Level 19

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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1142 views
  • 5 likes
  • 2 in conversation