Programming the statistical procedures from SAS

why the results from R and SAS are different ( 2 sample proportion test)

Reply
Frequent Contributor
Posts: 89

why the results from R and SAS are different ( 2 sample proportion test)

Dear All

Suppose I have following data set:

data test;
input row col count;
cards;
1 1 11
1 2 4
2 1 13
2 2 1
;
run;

Because this data set violates the proportion test assumption, I need to do continuity correction; and I also need to perform one sided test.

So I ran following codes:

proc freq data=test;
tables row*col/riskdiffc (EQUAL);
weight count;
run;

The one-sided p-value I got from running this SAS code is 0.1719.

However when I try to solve the exactly same problem using R, I got one-sided p-value=0.8157.

My question is: why the p-values from SAS and R are different?

Personally I think p-value=0.8157 (from R) is correct, as proportion1 is greater than proportion2 suggesting the p-value should be greater than 0.5.

Did I make any mistake in my SAS coding?
Super Contributor
Posts: 281

Re: why the results from R and SAS are different ( 2 sample proportion test)

I can't say if you made a mistake in your SAS coding until you tell us the exact hypothesis you want to test in SAS. What is "proportion1" and what is "proportion2"?

Maybe you made a mistake in your R coding?

Maybe SAS and R aren't programmed to do the same thing, in which case the results wouldn't match. Maybe they use different algorithms to answer the same question. Message was edited by: Paige
Trusted Advisor
Posts: 2,114

Re: why the results from R and SAS are different ( 2 sample proportion test)

There have been several books written on the analysis of 2x2 tables with 10's of different methods for continuity adjustment, so it is not surprising that the numbers don't match exactly.

The answers that you got are actually close. R and SAS just reversed the names for proportion 1 and 2 so they were looking at opposite tails in the one-tailed environment.
Ask a Question
Discussion stats
  • 2 replies
  • 115 views
  • 0 likes
  • 3 in conversation