BookmarkSubscribeRSS Feed
Zynep93
Obsidian | Level 7

Hello everyone, 

 

I am testing different kinds of fertilizers (frt) on plant height and biomass in the field. Treatments are randomly assigned, and there are no replications. I used Proc Anova; however, I came across this warning in the log. The picture is attached. What does this warning mean? 

 

Screenshot 2024-10-25 at 8.04.15 AM.png

I also tried glimmix code; but I am sure not if I have a random statement in the syntax. I would like to add lsmeans and turkey comparison in my code. 

 

Proc glimmix Data =LP;
class frt height biomass;
model biomass = frt;
random 
lsmeans frt*biomass / Adjust = Tukey lines slicediff= frt;
run;

 

Thank you for you help! 

 

 

12 REPLIES 12
PaigeMiller
Diamond | Level 26

if you read the PROC ANOVA documentation it warns you very clearly not to use it in certain situations.

 

Caution: If you use PROC ANOVA for analysis of unbalanced data, you must assume responsibility for the validity of the results.

 

You might want to do what the message says and use PROC GLM. In this simple experiment (at least that's how you describe it) with no replications, I think PROC GLM is fine, and no need for a RANDOM statement. But maybe there's more to it than your description ... ? PROC ANOVA's error message makes me think you might have multiple observations for each fertilizer.

 

--
Paige Miller
Zynep93
Obsidian | Level 7

I have replications of some treatments but not all of them; I want to analyze them as an individual treatment. But in general, I wouldn't say the experiments have replications as they do not apply to all. Might be the reason why it says there are multiple observations. In this case, is this the correct code?

proc glimmix data=LP;
class frt height biomass;
model frt= biomass;
lsmeans frt*biomass / Adjust = Tukey lines slicediff= frt;
run;

PaigeMiller
Diamond | Level 26

You can't say in your initial post that there are no replications and then later say you do have replications. This is very confusing, and makes it much harder for us to give good advice.

 

In this case, is this the correct code?

 

Run it and see. I don't have your data, I can't run it.

 

 

--
Paige Miller
Zynep93
Obsidian | Level 7
I could have said, there are replications but not equal. But again, it does not apply to all treaments. I think it is counted that there are replications.   I did run it and gave an error. 

'ERROR: ''Effects used in the LSMEANS statement must have appeared previously in the MODEL statement''
PaigeMiller
Diamond | Level 26

In your code, LSMEANS contains an interaction, but there is no interaction in the model. You can only put terms in the model into LSMEANS.

--
Paige Miller
Zynep93
Obsidian | Level 7
Where am I making a mistake? Should I use proc gee instead of proc glimmix? or I can not use probably lsmeans multinomial distributions? 
 
proc glimmix data=waterford;
class frt height biomass;
 model frt= biomass height;
lsmeans biomass height/ Adjust = Tukey lines slicediff= frt;
run; 
 
ERROR: Least-squares means are not available for the multinomial distribution.
Rick_SAS
SAS Super FREQ

If you post your data (or fake data that looks like it), we can give better advice. 

Zynep93
Obsidian | Level 7

Hello Rick, 

 

Thanks for your reply. I've attached the data. I tried both glimmix and proc gee, but I still got stuck. @Rick_SAS 

 

frt=fertilizer 

I collected data for 27 weeks for the same plants sprayed with different fertilizers, and I am looking to see if there is any significant difference between fertilizer treatments on plant height and biomass. 

 

 

Proc gee Data =Waterford;
class frt week;
model ph=frt;
repeated subject=frt/type=ar(1) covb ;
lsmeans frt*week/ cl diff plot=diff Adjust=Tukey lines;
run;

 

Error: Effects used in the LSMEANS statement must have appeared previously in the MODEL statement.

 

 

Proc glimmix Data =Waterford;
class frt week;
model ph = frt week frt*week/link=log dist=multinomial;
random week/subject=frt type=cs residual;
lsmeans frt*week / Adjust = Tukey lines slicediff= week;
output out=second predicted=pred residual=resid residual(noblup)=mresid student=studentresid student(noblup)=smresid;
run;

 

For the multinomial distribution only the following links are possible: CUMLOGIT, CUMPROBIT, CUMLOGLOG, CUMCLL, GLOGIT.

 

Thank you again. 

Ksharp
Super User
That would be better if you could post some sample data. @SteveDenham @StatDave would be happy to give you an hand.
And I think you missed the id of plant (a.k.a subject_id in Mixed Model) variable in your code.
Rick_SAS
SAS Super FREQ

There are others who have more experience with crop science than I do, but it looks like you could fit these data by using a mixed model to account for the correlations between time points. I think I would treat WEEK as continuous, not categorical. I don't understand what you are trying to do with the LSMEAN statement, so I'll let someone else advice you on that.

 

data Waterford; 
infile datalines expandtabs truncover; 
input frt$ ph Week;  
datalines; 
WOL 15.20 1 
WOH 20.30 1 
MEL 17.78 1 
MEH 20.30 1 
CbioL 22.86 1 
CbioH 22.80 1 
PCL 25.40 1 
PCH 20.32 1 
FFL 20.30 1 
FFH 20.30 1 
VIA 17.78 1 
VIM 17.78 1 
UCL2 17.78 1 
UCL3 17.78 1 
UCL5 17.78 1 
UCL6 17.78 1 
Control  15.20 1 
WOL 17.78 2 
WOH 21.59 2 
MEL 19.05 2 
MEH 21.59 2 
CbioL 24.13 2 
CbioH 24.13 2 
PCL 26.67 2 
PCH 22.86 2 
FFL 20.32 2 
FFH 19.05 2 
VIA  20.32  2 
VIM 19.05 2 
UCL2 24.13  2 
UCL3 21.59  2 
UCL5 19.05  2 
UCL6 16.51  2 
Control  22.86  2 
WOL 20.32 3 
WOH 31.75 3 
MEL 30.48 3 
MEH 22.86 3 
CbioL 25.40 3 
CbioH 24.89 3 
PCL 36.83 3 
PCH 27.94 3 
FFL 26.67 3 
FFH 21.59 3 
VIA   33.02 3 
VIM 29.21 3 
UCL2  25.40 3 
UCL3  27.94 3 
UCL5  19.81 3 
UCL6  26.67 3 
Control   26.67 3 
WOL 29.21 4 
WOH 44.45 4 
MEL 43.18 4 
MEH 33.02 4 
CbioL 33.02 4 
CbioH 26.67 4 
PCL 50.80 4 
PCH 50.80 4 
FFL 36.83 4 
FFH 30.48 4 
VIA   49.53 4 
VIM 40.64 4 
UCL2  25.40 4 
UCL3  38.10 4 
UCL5  0.00  4 
UCL6  0.00  4 
Control   43.18 4 
WOL 38.10 5 
WOH 55.88 5 
MEL 52.07 5 
MEH 33.78 5 
CbioL 38.10 5 
CbioH 30.48 5 
PCL 59.69 5 
PCH 55.88 5 
FFL 43.18 5 
FFH 38.10 5 
VIA   58.42 5 
VIM 55.88 5 
UCL2  26.67 5 
UCL3  46.99 5 
UCL5  0.00  5 
UCL6  0.00  5 
Control   50.80 5 
WOL 45.72 6 
WOH 60.96 6 
MEL 60.96 6 
MEH 45.72 6 
CbioL 48.26 6 
CbioH 43.18 6 
PCL 68.58 6 
PCH 68.58 6 
FFL 55.88 6 
FFH 50.80 6 
VIA   71.12 6 
VIM 73.66 6 
UCL2  30.48 6 
UCL3  60.96 6 
UCL5  0.00  6 
UCL6  0.00  6 
Control   66.04 6 
WOL 55.88 7 
WOH 73.66 7 
MEL 68.58 7 
MEH 53.34 7 
CbioL 53.34 7 
CbioH 48.26 7 
PCL 76.20 7 
PCH 73.66 7 
FFL 66.04 7 
FFH 58.42 7 
VIA   78.74 7 
VIM 78.74 7 
UCL2  33.02 7 
UCL3  76.20 7 
UCL5  0.00  7 
UCL6  0.00  7 
Control   78.74 7 
WOL 63.50 8 
WOH 81.28 8 
MEL 76.20 8 
MEH 60.96 8 
CbioL 60.96 8 
CbioH 55.88 8 
PCL 81.28 8 
PCH 83.82 8 
FFL 78.74 8 
FFH 63.50 8 
VIA   91.44 8 
VIM 88.90 8 
UCL2 35.56 8 
UCL3  81.28 8 
UCL5  0.00  8 
UCL6  0.00  8 
Control   86.36 8 
WOL 73.66 9 
WOH 88.90 9 
MEL 81.28 9 
MEH 68.58 9 
CbioL 71.12 9 
CbioH 63.50 9 
PCL 86.36 9 
PCH 86.36 9 
FFL 81.28 9 
FFH  71.12 9 
VIA   101.60  9 
VIM 91.44 9 
UCL2  35.56 9 
UCL3  86.36 9 
UCL5  40.64 9 
UCL6  35.56 9 
Control   88.90 9 
WOL 81.28 10 
WOH 93.98 10 
MEL 86.36 10 
MEH 71.12 10 
CbioL 76.20 10 
CbioH 66.04 10 
PCL 88.90 10 
PCH 93.98 10 
FFL 86.36 10 
FFH  76.20 10 
VIA   101.60  10 
VIM 106.68  10 
UCL2  35.56 10 
UCL3  99.06 10 
UCL5  60.96 10 
UCL6  50.80 10 
Control   96.52 10 
WOL 91.44 11 
WOH 106.68  11 
MEL 91.44 11 
MEH 76.20 11 
CbioL 93.98 11 
CbioH 83.82 11 
PCL 91.44 11 
PCH 101.60  11 
FFL 96.52 11 
FFH 88.90 11 
VIA   106.68  11 
VIM 114.30  11 
UCL2  45.72 11 
UCL3  116.84  11 
UCL5  86.36 11 
UCL6  63.50 11 
Control   104.14  11 
WOL 111.76  12 
WOH 114.30  12 
MEL 111.76  12 
MEH 114.30  12 
CbioL 114.30  12 
CbioH 101.60  12 
PCL 106.68  12 
PCH 111.76  12 
FFL 104.14  12 
FFH 99.06 12 
VIA   111.76  12 
VIM 104.14  12 
UCL2  63.50 12 
UCL3  129.54  12 
UCL5  93.98 12 
UCL6  91.44 12 
Control   114.30  12 
WOL 119.38  13 
WOH 121.92  13 
MEL 116.84  13 
MEH 116.84  13 
CbioL 111.76  13 
CbioH 106.68  13 
PCL 106.68  13 
PCH 116.84  13 
FFL 111.76  13 
FFH 106.68  13 
VIA   121.92  13 
VIM 119.38  13 
UCL2  93.98 13 
UCL3  119.38  13 
UCL5  106.68  13 
UCL6  106.68  13 
Control   121.92  13 
WOL 124.46  14 
WOH 134.62  14 
MEL 119.38  14 
MEH 121.92  14 
CbioL 116.84  14 
CbioH 109.22  14 
PCL 119.38  14 
PCH 132.08  14 
FFL 139.70  14 
FFH 137.16  14 
VIA   124.46  14 
VIM 137.16  14 
UCL2  96.52 14 
UCL3  127.00  14 
UCL5  121.92  14 
UCL6  111.76  14 
Control   132.08  14 
WOL 139.70  15 
WOH 149.86  15 
MEL 121.92  15 
MEH 127.00  15 
CbioL 119.38  15 
CbioH 111.76  15 
PCL 142.24  15 
PCH 139.70  15 
FFL 142.24  15 
FFH  142.24  15 
VIA   132.08  15 
VIM 142.24 15 
UCL2 99.06  15 
UCL3  134.62  15 
UCL5  147.32  15 
UCL6  127.00  15 
Control   137.16  15 
WOL 142.24  16 
WOH 154.94  16 
MEL 129.54  16 
MEH 129.54  16 
CbioL 129.54  16 
CbioH 114.30  16 
PCL 147.32  16 
PCH 142.24  16 
FFL 147.32  16 
FFH 144.78  16 
VIA   134.62  16 
VIM 144.78  16 
UCL2  104.14  16 
UCL3  144.78  16 
UCL5  152.40  16 
UCL6  132.08  16 
Control   139.70  16 
WOL 157.48  17 
WOH 172.72  17 
MEL 147.32  17 
MEH 132.08  17 
CbioL 154.94  17 
CbioH 114.30  17 
PCL 157.48  17 
PCH 160.02  17 
FFL 149.86  17 
FFH 147.32  17 
VIA   172.72  17 
VIM 175.26  17 
UCL2  106.68  17 
UCL3  149.86  17 
UCL5  160.02  17 
UCL6  152.40  17 
Control   160.02  17 
WOL 160.02  18 
WOH 175.26  18 
MEL 152.40  18 
MEH 134.62  18 
CbioL 157.48  18 
CbioH 127.00  18 
PCL 162.56  18 
PCH 165.10  18 
FFL 154.94  18 
FFH 152.40  18 
VIA   172.72  18 
VIM 177.80  18 
UCL2  114.30  18 
UCL3  154.94  18 
UCL5  165.10  18 
UCL6  157.48  18 
Control   162.56  18 
WOL 165.10  19 
WOH 180.34  19 
MEL 154.94  19 
MEH 137.16  19 
CbioL 162.56  19 
CbioH 127.00  19 
PCL 167.64  19 
PCH 167.64  19 
FFL 160.02  19 
FFH 160.02  19 
VIA   175.26  19 
VIM 180.34  19 
UCL2  119.38  19 
UCL3  157.48  19 
UCL5  193.04  19 
UCL6  162.56  19 
Control   167.64  19 
WOL 167.64  20 
WOH 182.88  20 
MEL 157.48  20 
MEH 149.86  20 
CbioL 167.64  20 
CbioH 129.54  20 
PCL 170.18  20 
PCH 172.72  20 
FFL 165.10  20 
FFH 185.42  20 
VIA   177.80  20 
VIM 185.42  20 
UCL2  121.92  20 
UCL3  160.02  20 
UCL5  220.98  20 
UCL6  165.10  20 
Control   175.26  20 
WOL 180.34  21 
WOH 203.20  21 
MEL 160.02  21 
MEH 152.40  21 
CbioL 172.72  21 
CbioH 129.54  21 
PCL 170.18  21 
PCH 177.80  21 
FFL 167.64  21 
FFH 185.42  21 
VIA 200.66  21 
VIM 218.44  21 
UCL2  152.40  21 
UCL3  193.04  21 
UCL5  264.16  21 
UCL6  180.34  21 
Control   203.20  21 
WOL 180.34  22 
WOH 208.28  22 
MEL 162.56  22 
MEH 154.94  22 
CbioL 175.26  22 
CbioH 132.08  22 
PCL 175.26  22 
PCH 182.88  22 
FFL 172.72  22 
FFH 187.96  22 
VIA   205.74  22 
VIM 223.52  22 
UCL2  154.94  22 
UCL3  198.12  22 
UCL5  266.70  22 
UCL6  182.88  22 
Control   208.28  22 
WOL 182.88  23 
WOH 210.82  23 
MEL 165.10  23 
MEH 157.48  23 
CbioL 177.80  23 
CbioH 134.62  23 
PCL 177.80  23 
PCH 185.42  23 
FFL 175.26  23 
FFH 190.50  23 
VIA   208.28  23 
VIM 223.52  23 
UCL2  160.02  23 
UCL3  198.12  23 
UCL5  274.32  23 
UCL6  185.42  23 
Control   213.36  23 
WOL 185.42  24 
WOH 215.90  24 
MEL 170.18  24 
MEH 160.02  24 
CbioL 182.88  24 
CbioH 134.62  24 
PCL 177.80  24 
PCH 187.96  24 
FFL 177.80  24 
FFH 190.50  24 
VIA   213.36  24 
VIM 226.06  24 
UCL2  162.56  24 
UCL3  200.66  24 
UCL5  287.02  24 
UCL6  187.96  24 
Control   215.90  24 
WOL 190.50  25 
WOH 220.98  25 
MEL 175.26  25 
MEH 165.10  25 
CbioL 185.42  25 
CbioH 134.62  25 
PCL 182.88  25 
PCH 193.04  25 
FFL 180.34  25 
FFH 193.04  25 
VIA   215.90  25 
VIM 274.32  25 
UCL2  167.64  25 
UCL3  208.28  25 
UCL5  287.02  25 
UCL6  190.50  25 
Control   215.90  25 
WOL 190.50  26 
WOH 220.98  26 
MEL 175.26  26 
MEH 165.10  26 
CbioL 185.42  26 
CbioH 137.16  26 
PCL 182.88  26 
PCH 193.04  26 
FFL 180.34  26 
FFH  193.04  26 
VIA   215.90  26 
VIM 274.32  26 
UCL2  167.64  26 
UCL3  208.28  26 
UCL5  287.02  26 
UCL6  190.50  26 
Control 215.90  26 
WOL 190.50  27 
WOH 220.98  27 
MEL 175.26  27 
MEH 165.10  27 
CbioL 187.96  27 
CbioH 137.16  27 
PCL 182.88  27 
PCH 195.58  27 
FFL 180.34  27 
FFH 195.58  27 
VIA   215.90  27 
VIM 276.86  27 
UCL2  170.18  27 
UCL3  208.28  27 
UCL5  289.56  27 
UCL6  190.50  27 
Control 215.90 27                                                    
; 

proc freq data=Waterford;
tables frt;
run;

title "Response by Week";
proc sgplot data=Waterford;
   series x=Week y=ph / group=frt;
run; 

proc mixed data=Waterford method=ml;
   class frt;
   model ph = frt week / s;
   repeated / type=ar(1) sub=frt;
   store out=MixedModel;                       /* create item store */
run;
 
proc plm restore=MixedModel;                   /* use item store to create fit plots */
   effectplot slicefit(x=week sliceby=frt);    /* overlay */
run;

Rick_SAS_0-1730368705652.png

 

 

Zynep93
Obsidian | Level 7

Thanks for all your help. @Ksharp @Rick_SAS 

The reason why I want to use Lsmeans statement is that I want to see differences in groups (fertilizers) and weeks, if any. When I run the code, I do not see p values in fixed effects. 

Ksharp
Super User

/*G-side Random Effect*/
proc mixed data=Waterford covtest;
   class frt ;
   model ph =  week / s ddfm=kr;
   random int week/subject=frt s;
run;
 


/*R-side Random Effect*/
proc mixed data=Waterford covtest;
   class frt week;
   model ph =  week / s ddfm=kr;
   repeated week/ type=ar(1) sub=frt ;
run;
 

R-side Random Effect Model has less AIC,BIC than G-side, then I would like to take R-side Model.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 12 replies
  • 2692 views
  • 5 likes
  • 4 in conversation