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

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 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