BookmarkSubscribeRSS Feed
always-good
Obsidian | Level 7

Hello everyone,

My data contains milk production parameters as the variables are: Milk, Fat, and Protein in the row of the excel file and the breed of the animal (1, 2) and the month (1,2,3,4 ) in the column.

so, for each month and each breed, we have the milk production parameters (milk, fat, and protein).

I want to see the effect of breed, month, and their interaction on these parameters (milk, fat, and protein).

I wonder about the glm procedure:

proc glm ;

model Milk Fat Protein= breed month breed * month ;

but I was asked to do the two-way ANOVA analysis and I wrote this code:

proc univariate data=milk ;
var Milk Fat Protein ;
run;

Is the code for the two-way ANOVA correct to see the effect of the breed the month and their interaction?

What is the difference between the proc glm and univariate if they can do the same test?

Thank you! and I am sorry for my lack of knowledge.

7 REPLIES 7
ballardw
Super User

I don't see anything that Proc Univariate code doing any ANOVA. It gives summary statistics of three variables and does not use the Breed or Month at all. So I don't quite understand why you are asking about comparison between Univariate and GLM at all.

 


@always-good wrote:

Hello everyone,

My data contains milk production parameters as the variables are: Milk, Fat, and Protein in the row of the excel file and the breed of the animal (1, 2) and the month (1,2,3,4 ) in the column.

so, for each month and each breed, we have the milk production parameters (milk, fat, and protein).

I want to see the effect of breed, month, and their interaction on these parameters (milk, fat, and protein).

I wonder about the glm procedure:

proc glm ;

model Milk Fat Protein= breed month breed * month ;

but I was asked to do the two-way ANOVA analysis and I wrote this code:

proc univariate data=milk ;
var Milk Fat Protein ;
run;

Is the code for the two-way ANOVA correct to see the effect of the breed the month and their interaction?

What is the difference between the proc glm and univariate if they can do the same test?

Thank you! and I am sorry for my lack of knowledge.


 

always-good
Obsidian | Level 7
@ballardw Thank you for your reply.
In fact, I think that I'm not writing the right code when the proc univariate is used to do Two-way ANOVA because I did not mention the breed and month. That's why I was asking. so please, what is the right code for the two-way ANOVA analysis without talking about glm procedure if it is not the proc univariate?
always-good
Obsidian | Level 7
Thank you!
PaigeMiller
Diamond | Level 26

Do not use PROC ANOVA for two-way ANOVA unless the cell sizes are all equal.

 

From the documentation for PROC ANOVA

 

The ANOVA procedure is designed to handle balanced data (that is, data with equal numbers of observations for every combination of the classification factors)

--
Paige Miller
PaigeMiller
Diamond | Level 26
proc glm ;
    model Milk Fat Protein= breed month breed * month ;

 

This looks like a two-way ANOVA to me.

 

Please, from now on @always-good, please use a code box to include actual code in your message. The above code box is created by clicking on the "little running man" icon and pasting your code into the window that appears.

--
Paige Miller
always-good
Obsidian | Level 7
Ok I will use the code box.
Thank you!

sas-innovate-wordmark-2025-midnight.png

Register Today!

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.


Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 1544 views
  • 5 likes
  • 4 in conversation