BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
palolix
Pyrite | Level 9

Dear SAS Community,

 

Looking at the this graph, I would like to know if the percentage of PeelColor 3 (red)  is significantly different between the Variety BL516 and Hass for the Season 2021. PeelColor is the dep categorical variable (ordinal) with more than 2 levels.

palolix_2-1747183129762.png

 

If I am correct, with an lsmestimate statement I should be able to answer that, so this is the code I am using. However I would like to know how to specify the level of the dep var (PeelColor=3) for this comparison. 

 

proc logistic data=one desc;
where Season=2021;
class Variety/param=glm;
model PeelColor= Variety/ link=clogit/*y is ordinal*/ ;
lsmeans Variety/diff;
lsmestimate Variety 'BL516 vs Hass' 0 0 0 0 0 1 0 0 0 0 -1/adjust=simulate(seed=1);
run;

 

I would greatly appreciate your help!

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
StatDave
SAS Super FREQ

A logistic model for this is overkill. For what you want, you can just use PROC FREQ since you are only looking at data for 2021. Also, I would assume that PeelColor is a nominal response, not ordinal, unless you are really interested in the color frequency. Effectively, you just have data for a 2x2 table with Variety as the rows and PeelColor (red vs anything else) as the columns. So, create a ColorRed variable which is 1 for Red and 0 otherwise and the use PROC FREQ:

proc freq; 
where season=2021;
table variety*colorred/chisq;
run;

This tests whether the proportions of ColorRed in the two varieties are equal.

View solution in original post

9 REPLIES 9
StatDave
SAS Super FREQ

A logistic model for this is overkill. For what you want, you can just use PROC FREQ since you are only looking at data for 2021. Also, I would assume that PeelColor is a nominal response, not ordinal, unless you are really interested in the color frequency. Effectively, you just have data for a 2x2 table with Variety as the rows and PeelColor (red vs anything else) as the columns. So, create a ColorRed variable which is 1 for Red and 0 otherwise and the use PROC FREQ:

proc freq; 
where season=2021;
table variety*colorred/chisq;
run;

This tests whether the proportions of ColorRed in the two varieties are equal.

palolix
Pyrite | Level 9

Thank you so much for your reply StatDave, that makes sense.

 

I will then apply these steps for every level of the dep var PeelColor I'm interested in, in order to get a 2x2 table:

 

data one1; set one;
if PeelColor=3 then ColorRed=1;
else ColorRed=0;
run;

 

proc freq data=one1;
where Season=2021 and Variety in('BL516', 'Hass');
table Variety*colorRed/chisq riskdiff;
run;

palolix
Pyrite | Level 9

I have a question; Is the two-sided Pearson chi-square test  in the Fisher's Exact Test Table the one that will tell me if  the proportions for ColorRed (1) are significantly different between the two Varieties? 

 

Frequency
Percent
Row Pct
Col Pct
Table of Variety by Colorred
Variety Colorred
0 1 Total
BL516
224
37.27
74.42
44.01
77
12.81
25.58
83.70
301
50.08
 
 
Hass
285
47.42
95.00
55.99
15
2.50
5.00
16.30
300
49.92
 
 
Total
509
84.69
92
15.31
601
100.00


 

Statistics for Table of Variety by Colorred

Statistic DF Value Prob
Chi-Square 1 49.0915 <.0001
Likelihood Ratio Chi-Square 1 53.0439 <.0001
Continuity Adj. Chi-Square 1 47.5168 <.0001
Mantel-Haenszel Chi-Square 1 49.0098 <.0001
Phi Coefficient   -0.2858  
Contingency Coefficient   0.2748  
Cramer's V   -0.2858  

Fisher's Exact Test
Cell (1,1) Frequency (F) 224
Left-sided Pr <= F <.0001
Right-sided Pr >= F 1.0000
   
Table Probability (P) <.0001
Two-sided Pr <= P <.0001
SAS_Rob
SAS Employee

Yes, the Pearson Chi-Square test will test the equality of the two proportions as detailed in this usage note.

22561 - Testing the equality of two or more proportions from independent samples

If you want an exact test, then you can report Fisher's exact test.

palolix
Pyrite | Level 9

Thanks. So should I use the Fisher's exact test (two -sided Pr<=P) in case the cell counts are too small, but otherwise the Chi square test I get with the chisq option?

Ksharp
Super User
As StatDave said, no need PROC LOGISTIC.
PROC FREQ + riskdiff option OR relrisk option is more than suffice.

https://support.sas.com/kb/23/003.html
https://support.sas.com/kb/57/798.html
palolix
Pyrite | Level 9

Thank you very much Ksharp for this useful option!

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 9 replies
  • 1320 views
  • 5 likes
  • 4 in conversation