BookmarkSubscribeRSS Feed
jake_t1876
Calcite | Level 5

The Cultivar variable is not recognized as categorical for the ANOVA. Any suggestions/recommendations on correcting this issue and anything else you might notice? Thanks!

data rice_yield;

    input Soil $ Cultivar $ Yield;

    datalines;

Soil_I Cultivar_1 100

Soil_I Cultivar_2 73

Soil_I Cultivar_3 89

Soil_I Cultivar_4 37

Soil_I Cultivar_5 120

Soil_II Cultivar_1 105

Soil_II Cultivar_2 59

Soil_II Cultivar_3 91

Soil_II Cultivar_4 41

Soil_II Cultivar_5 115

Soil_III Cultivar_1 93

Soil_III Cultivar_2 65

Soil_III Cultivar_3 79

Soil_III Cultivar_4 43

Soil_III Cultivar_5 105

;

run;

/* Perform two-way ANOVA with interaction */

proc anova data=rice_yield;

    class Soil Cultivar;  /* Declare categorical variables */

    model Yield = Soil|Cultivar;  /* Include interaction term */

    means Soil Cultivar / tukey;  /* Post-hoc comparisons */

run;

Screenshot 2024-09-10 at 5.35.36 PM.pngScreenshot 2024-09-10 at 5.35.22 PM.png

4 REPLIES 4
Ksharp
Super User

That is because the data you imported in is NOT right.

Ksharp_0-1726016212836.png

 

Change your data step code to import it correctly .

data rice_yield;
    input Soil $ Cultivar :$32. Yield;
    datalines;
...............

Ksharp_1-1726016340486.png

 

jake_t1876
Calcite | Level 5

How does the ":$32" change the inputs?

 

Ksharp
Super User
?? It is LIST INPUT method, with it you could get variable "Cultivar" has more length 32,not 8 by default, to include "_2" "_3".
You can see the change:
Cultivar -> Cultivar_1
Cultivar -> Cultivar_2
jake_t1876
Calcite | Level 5

Thanks you so much for the explanation!!

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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