Statistical Procedures

Programming the statistical procedures from SAS
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
wateas
Obsidian | Level 7

Using a mixed effects model in PROC GLIMMIX, I would like to determine the differences between lsmeans with a chosen control.  I'm trying to mimic the method outlined in the documentation to the best of my ability, but I get an error indicating "cannot find control level".

proc glimmix data=df_y1 plots=studentpanel;
	class Trt_Amend_App Trt_CC ID_S Block;
	model Yield_Grain_Mg_ha = Trt_Amend_App | Trt_CC | ID_S / ddfm=kr2;
	random Block(ID_S);
    lsmeans Trt_Amend_App * Trt_CC / pdiff=control('7' '2') adjust=dunnett;
run;

The control corresponds to the 7th level of factor Trt_Amend_App and the 2nd level of Trt_CC.  Any help clarifying this issue would be much appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

If you have a format attached with these two variables( Trt_Amend_App  Trt_CC ) ,you need to use their FORMATTED value ,not internal value.

Using PROC FREQ to check its value:

 

proc freq data=df_y1;
table Trt_Amend_App * Trt_CC ;
run;

View solution in original post

5 REPLIES 5
Ksharp
Super User

If you have a format attached with these two variables( Trt_Amend_App  Trt_CC ) ,you need to use their FORMATTED value ,not internal value.

Using PROC FREQ to check its value:

 

proc freq data=df_y1;
table Trt_Amend_App * Trt_CC ;
run;
wateas
Obsidian | Level 7

Edited: There was an error in my factor level strings causing the issue.  The code below works otherwise.  Thanks.

 

Hey Ksharp - thank you for your response.

From running PROC FREQ, I see that I can easily see the level values, but I'm not sure exactly what you mean that I need to use their 'FORMATTED values'.  PROC CONTENTS indicates that these factors are all type "char". 

 

This code returned the same error, "cannot find control level for effect...":

    lsmeans Trt_Amend_App * Trt_CC / pdiff=control('Control-Fert-nan' 'no_CC') adjust=dunnett;

 

data_null__
Jade | Level 19

You need to show us some output.

Show the result of LSMEANS without Control;

 

lsmeans Trt_Amend_App * Trt_CC / pdiff;
wateas
Obsidian | Level 7

Hey now that I'm looking at it again, I appear to have made a error with my strings!  So the problem is solved now.  Thanks for your help.

Ksharp
Super User
E.X.
proc format;
value fmt
1='X'
2='Y'
;
run;

and the value of Trt_CC variable is 1,2
Therefore,
'X' ,'Y' is the FORMATTED values.
1,2 is the internal values.

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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
  • 1081 views
  • 1 like
  • 3 in conversation