BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ArmandoTasistro
Obsidian | Level 7

I run the ANOVA Procedure using SAS Studio (SAS University Edition) for the data from a split-plot experiment (see attached sas file). From page 3 onwards of the attached results file, one can see the output of the Means Procedure.

I cannot find:

  • the means for the three K treatments.
  • the LSD values to compare those three means
  • the LSD values to compare the means of the interaction effects between the "cal" and "K" factors (Table in page 7).

Your advice will be appreciated.

Armando

 

1 ACCEPTED SOLUTION

Accepted Solutions
ArmandoTasistro
Obsidian | Level 7

Thank you so much @PaigeMiller ! You have been very helpful!

I will look into using the LSMEANS statement.

View solution in original post

14 REPLIES 14
PaigeMiller
Diamond | Level 26

As I no longer am willing to download files from this web site, please paste your code as text into your message using the "running man" icon and please paste the output into your message as a screen capture(s), using the "Insert Photos" icon.

--
Paige Miller
ArmandoTasistro
Obsidian | Level 7
data sp;
     input Block cal K rend @@;
     datalines;
      1 0   0  1949
      2 0   0  1955
      3 0   0  1874
      1 0  90  2385
      2 0  90  2319
      3 0  90  2339
      1 0 180  5042
      2 0 180  4866
      3 0 180  4778
      1 2   0  7529
      2 2   0  7694
      3 2   0  6863
      1 2  90     .  
      2 2  90  8484
      3 2  90  7410
      1 2 180     .
      2 2 180     .  
      3 2 180  7779
    ;
proc anova data=sp;
      class cal K Block;
      model rend = cal K cal*K Block cal*Block;
      test h=cal e=cal*Block;
      means cal K cal*K / lsd;
   run;

output4.JPGoutput3.JPGoutput2.JPGoutput1.JPG

mkeintz
PROC Star

@ArmandoTasistro 

 

I agree with @PaigeMiller in requesting you actually insert the code in the sas code popup produced by the running man.  Please encourage us to help you by not obligating us to download something that this web site makes easy for you to post.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
ArmandoTasistro
Obsidian | Level 7
@mkeintz

Thank you for your reply and interest to assist. I am not familiar with the site, and I was just following the options provided. Maybe, if downloading is not convenient, it should be removed as an option.
mkeintz
PROC Star

@ArmandoTasistro 

 

Thanks for posting the code.   I looked up the documentation for the means statement in proc anova, and couldn't see why you didn't get the one-way means.  I would expect them too.

 

But dropping the "/ lsd" option gave the desired means, but then dropped the pairwise t tests.

 

However, I did produce what I think you want by entering two MEANS statements, one with the /lsd and one without:

 

proc anova data=sp;
 class cal K Block;
 model rend = cal K cal*K Block cal*Block;
 test h=cal e=cal*Block;
 means cal K cal*K ;
 means cal K cal*K / lsd ;
 run;
quit;
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
ArmandoTasistro
Obsidian | Level 7

@mkeintz 

 

Thank you for your input that helped me obtain the three K means.

However, I am missing the following:

 

  • the LSD values to compare the three K means
  • the LSD values to compare the means of the interaction effects between the "cal" and "K" factors (Table in page 7).

 

PaigeMiller
Diamond | Level 26

First, you need to be aware of the limitation of PROC ANOVA. The documentation says:

 

Use PROC ANOVA for the analysis of balanced data only, with the following exceptions: one-way analysis of variance, Latin square designs, certain partially balanced incomplete block designs, completely nested (hierarchical) designs, and designs with cell frequencies that are proportional to each other and are also proportional to the background population. These exceptions have designs in which the factors are all orthogonal to each other.

So, I don't think you should use this PROC for your data, as I'm pretty sure it is giving questionable results. You want to use PROC GLM.

 

Your PROC ANOVA, which may be producing the wrong answers, does provide tables of means as you requested, sometimes in the form of an LSD chart (which is what you requested). If you add in the LINES or LINESTABLE option, you will see them more clearly. If you don't want the graphical comparisons of means and just want them in a table, use the command ODS GRAPHICS OFF; before you run PROC GLM.

--
Paige Miller
ArmandoTasistro
Obsidian | Level 7

@PaigeMiller 

 

Thank you for your help. I have made progress, and now I'm missing only the LSD values to compare the means shown in the last table (page 7 of the output), which corresponds to the cal * K interaction effects. Since the data came from a split-plot design, different error terms must be used, depending on the comparisons of interest. I don't know why I am not getting this part of the results.

PaigeMiller
Diamond | Level 26

I don't think the MEANS statement gives LSD tests for interactions.

 

You can compare the interactions using the LSMEANS statement and the LINES option.

--
Paige Miller
ArmandoTasistro
Obsidian | Level 7

Thank you so much @PaigeMiller ! You have been very helpful!

I will look into using the LSMEANS statement.

SteveDenham
Jade | Level 19

I will go even farther than @PaigeMiller , and suggest you use PROC MIXED as you have a randomized complete block design.  This procedure will treat the blocks as random effects, which will help with any inferences you have beyond the blocks included in your study.  The lsmeans should not be different, but the GLM analysis leads to a narrow inference space (what you would expect to happen if you repeated the experiment many times on exactly the same blocks), while the MIXED analysis leads to a broad inference space (what you would expect to happen you repeated the experiment many times on blocks sampled from all possible blocks).  Try this code:

 

proc mixed data=sp;
 class cal K Block;
 model rend = cal K cal*K;
 random block;
 lsmeans cal K cal*K/diff ;
 run;

SteveDenham

 

ArmandoTasistro
Obsidian | Level 7

@SteveDenham 

 

Thank you very much for providing further and valuable advice.

 

I used the code that you suggested with a the addition of the cal*Block effect in the random statement, to account for the split-plot design.

I am going to compare the outputs, but I could immediately see that the means comparisons differ. Apparently, LSDs cannot be estimated with Proc MIXED.

 

 

proc mixed data=sp;
      class cal K Block;
      model rend = cal K cal*K;
      random block cal*Block;
      lsmeans cal K cal*K/diff ;
 run;
SteveDenham
Jade | Level 19

@ArmandoTasistro ,

 

I take your statement to mean that MIXED does not report an LSD value.  The issue is that since there are two sources of variability, the classical LSD value is difficult to calculate.  And it isn't really needed - the diff option to the LSMEANS statement provides the equivalent of a t test between the least squares means in question.  That is exactly what an LSD does.  If you need a calculated LSD, look at the t value reported for (EDIT: the difference between) any two means, and rearrange the following equation to solve for t(df,0.95).

 

pdiff = CDF('T',calculated t value, df) to 

t(df,0.95 two tailed) = QUANTILE ('T",0.975, df).

 

Once you have t(df, 0.95 two tailed) the LSD is t(df, 0.95 two tailed) * std error of the difference.  The std error of the difference should be presented in the table of lsmean differences, so it is just a simple multiplication to get a calculated LSD.

 

SteveDenham

ArmandoTasistro
Obsidian | Level 7

@SteveDenham 

 

Thank you so much! I will try to test your suggestion.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 14 replies
  • 3108 views
  • 0 likes
  • 4 in conversation