BookmarkSubscribeRSS Feed
sasnewbie97
Calcite | Level 5

Hi 

IM A BEGINNER IN SAS .

NEED TO PERFORM ANALYSIS TO  MY DEPENDENT AND INDEPENDENT VARIABLES TO CHECK FOR HYPOTHESES.

MY DEPENDENT VARIABLE  :   TENSION

    INDEPENDENT VARIABLES : COTTON

 

Here is the code I wrote:

 

DATA fiber;
INPUT cotton $ tension @@;
CARDS;
15 7 15 7 15 15 15 11 15 9
20 12 20 17 20 12 20 18 20 18
25 14 25 18 25 18 25 19 25 19
30 19 30 25 30 22 30 19 30 23
35 7 35 10 35 11 35 15 35 11
;
RUN;
proc anova data=fiber;
class cotton;
model cotton=tension ;
means cotton/ lines alpha=0.01 lsd;
means cotton/ hovtest=bartlett;
run;
quit;

 

However I got three error messages:

ERROR: Variable cotton  in list does not match type prescribed for this list.

ERROR:  Effects used in the MEANS statement must have appeared previously in the MODEL statement.

ERROR:  Effects used in the MEANS statement must have appeared previously in the MODEL statement.

 

COULD SOMEBODY HELP ME WITH WHAT KIND OF  ERRORS  ARE THESE /ANY OTHER WAY TO PERFORM ANALYSIS FOR ALL THESE VARIABLE ALTOGETHER.

 

 

THANKS IN ADVANCE.

5 REPLIES 5
PaigeMiller
Diamond | Level 26

Seems to me, this is backwards

 

model cotton=tension ;

 

If you want cotton to be the independent variable and tension to be the dependent variable, the above code is wrong, you have specified the opposite.

 

From now on, please post code by clicking on the "Little Running Man" icon and pasting the code into the window that appears. From now on, please provide the ENTIRE log for the PROC or DATA step with the problem; not just the error messages, by clicking on the </> icon and pasting the log into the window that appears. From now on, DO NOT TYPE IN ALL CAPITALS. Thanks!

--
Paige Miller
Ksharp
Super User
/*
I think you should switch into PROC GLM for HOVTEST.
proc anova is only suited for balance design.
proc glm is suited for bothe balance and unbalance design.
But since your data is balance design(each cotton group have five obs),
you could use proc anova, but you should take COTTON as independent variable in model.
*/
DATA fiber;
INPUT cotton $ tension @@;
CARDS;
15 7 15 7 15 15 15 11 15 9
20 12 20 17 20 12 20 18 20 18
25 14 25 18 25 18 25 19 25 19
30 19 30 25 30 22 30 19 30 23
35 7 35 10 35 11 35 15 35 11
;
RUN;
proc anova data=fiber;
class cotton;
model tension=cotton ;  /*<-- Here is */
means cotton/ lines alpha=0.01 lsd;
means cotton/ hovtest=bartlett;
run;
quit;

Ksharp_0-1685705709708.png

 

PaigeMiller
Diamond | Level 26

proc anova is only suited for balance design.

 

This is true for two-way and higher experimental designs. For one-way anova, which this is, it will handle balanced or unbalanced properly.

--
Paige Miller
ballardw
Super User

. In analysis of variance, a continuous response variable, known as a dependent variable,is measured under experimental conditions identified by classification variables, known as independent variables.

 

You variable COTTON is character. So it is not continuous. If that was not intentional then you need to fix your INPUT statement.

The $ next to cotton in this code makes the variable character:

DATA fiber;
INPUT cotton $ tension @@;
CARDS;
15 7 15 7 15 15 15 11 15 9
20 12 20 17 20 12 20 18 20 18
25 14 25 18 25 18 25 19 25 19
30 19 30 25 30 22 30 19 30 23
35 7 35 10 35 11 35 15 35 11
;
RUN;

So on the model statement:

model cotton=tension ;

You have cotton as the dependent variable and the value for ANOVA has to be numeric. Which is why you get this error:

ERROR: Variable cotton  in list does not match type prescribed for this list.

SAS basically only has two types of variables, numeric or character. So when you get "does not match type" you know that the value should be of the other type. SAS is even nice enough to tell you which variable.

The base syntax for model statements is

MODEL dependents = effects </ options>; 

There are many regression procedures with Model statements. All follow this general syntax.

 

The other two errors occur because of the first error (not uncommon). Since the MODEL statement is syntactically incorrect because of where Cotton appears there is no Model statement in effect. That generates the errors related to effects not appearing on the (non-existent) Model statement.

 

SteveDenham
Jade | Level 19

To follow up on @ballardw 's guidance - I think all of your error messages can be dealt with by removing the $ in your INPUT statement.

 

SteveDenham

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 576 views
  • 2 likes
  • 5 in conversation