turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- why the results from R and SAS are different ( 2 ...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

05-31-2011 09:33 PM

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?

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?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-01-2011 08:19 AM

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

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-01-2011 10:09 AM

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.

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.