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
- /
- SAS Programming
- /
- Base SAS Programming
- /
- Analysis of a 2x2 Contingency Table

Topic Options

- 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
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-15-2018 02:21 PM - edited 04-15-2018 02:22 PM

I want to create a crosstabulation table between Region and season:

Spring | Summer | p-value | |

Region 1 | .. % | ..% | P1 |

Region 2 | .. % | .. % | P2 |

Region 3 | ..% | .. % | P3 |

I want to:

Check if the % of people in region 1 is different between spring and summer (p-value or OR)

Check if the % of people in region 2 is different between spring and summer (p-value or OR)

Check if the % of people in region 3 is different between spring and summer (p-value or OR)

**What test should I use to get the 3 p-values needed?**

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

Posted in reply to sebai

04-15-2018 02:30 PM

As far as I remember, a simple comparison of proportions as you describe (which is not really a 2x2 contingency table at all) is not programmed into any SAS PROC. However, it is simple enough to program in data step.

As is usual, @Rick_SAS has written up the explanation at https://blogs.sas.com/content/iml/2017/07/05/test-equality-two-proportions-sas.html

--

Paige Miller

Paige Miller

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

Posted in reply to sebai

04-15-2018 03:25 PM

It's not a 2X2 table, since it's literally a 1 (row=REGION) X 2 (column=SEASON) comparison.

One way would be to use a BY statement in the PROC FREQ.

Here's an example that gets the binomial test, which tests that the proportions should be 50% in each group. Note that you'll need the N's here, NOT the percentages. You need both the N and percentages or the raw data.

```
proc sort data=sashelp.class out=class; by age sex; run;
ods output binomialTest=pvalues;
proc freq data=class;
by age;
table sex / out=summary_table chisq binomial;
run;
```

PS. The reusults are not in a nice neat table, but all the information is in the two output tables:

- Summary_Table -> has the counts and percentages
- Values -> has the p-values for each test