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
- /
- calculate odds ratio (OR)

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

06-20-2017 04:47 PM

I have a group of variables I'd like to calculate their ORs, if possible all once and including 95% CI

Here is what the data looks like. The categorical variable Race (white or black) used for two comparison groups. I want to calculate the ORs between W and B for Var1-Var5. Is there a good/easy way to get the ORs and 95%CIs for all the variables? Thanks.

Obs Race Var1 Var2 Var3 Var4 Var5

1 W 1 0 1 1 0

2 B 0 1 0 1 1

3 B 0 1 0 1 1

4 W 0 0 0 0 0

5 W 1 0 1 0 0

6 W 1 1 1 0 1

7 B 1 0 1 0 0

8 W 1 1 1 1 1

9 B 1 0 1 1 0

10 B 0 1 0 0 1

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

Posted in reply to Xiaoyi

06-20-2017 06:18 PM

Have you tried PROC FREQ?

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

Posted in reply to Reeza

06-20-2017 09:43 PM

Here's an example with PROC FREQ. You may need to switch around the variables to ensure your analysis is correct.

```
data have;
input Obs Race $ Var1 Var2 Var3 Var4 Var5;
cards;
1 W 1 0 1 1 0
2 B 0 1 0 1 1
3 B 0 1 0 1 1
4 W 0 0 0 0 0
5 W 1 0 1 0 0
6 W 1 1 1 0 1
7 B 1 0 1 0 0
8 W 1 1 1 1 1
9 B 1 0 1 1 0
10 B 0 1 0 0 1
;
run;
proc print data=have;
run;
proc freq data=have;
table race * (var1-var5)/ Oddsratio;
run;
```

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

Posted in reply to Reeza

06-21-2017 11:21 AM

Thank you Reeza for your quick and helpful response. I run into another problem that some of the count of a response is zero. if we use traditional method to calculate ORs, one of the cells in a 2X2 table would be 0, it would cause the OR is zero or not be able to be calculated. Do you have any suggestion about how to deal with such a situation? Thanks again.

e.g. exposed not exposed

Disease 0 3

No-disease 210 340

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

Posted in reply to Xiaoyi

06-21-2017 12:45 PM

The odds ratio for a 2x2 table is defined as

OR = (n11*n22) / (n12*n21)

so the odds ratio for your example is 0.

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

Posted in reply to Rick_SAS

06-21-2017 01:19 PM

Thanks for your response. Technically, yes, it would be zero, but in a practical term, it is not very meaningful. I think there should be some way to be able to estimate the risk (OR) even when the frequency of one outcomes is 0.

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

Posted in reply to Xiaoyi

06-21-2017 02:02 PM

From a frequentist point of view, the estimate is zero. Are you looking for a Bayesian analysis?

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

Posted in reply to Xiaoyi

06-21-2017 02:05 PM

Xiaoyi wrote:

It means that your sample size was too small for the event you're trying to observe.

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

Posted in reply to Reeza

06-21-2017 06:22 PM

That's true. The sample given here is just an example for easy calculation in SAS. My real data set has more than 60 000 observations.

one example of the counts from 2X2 table from my data: exposed not-exposed

disease 0 8

no disease 2254 63700

It is a rare disease situation. Some would say the OR is zero or can't be calculated. I am looking for a way to estimate the risk/association between factors in a more meaningful way. Some said adding 0.5 to each sell. I am not sure if it would work with SAS or if it is biased.

Any suggestion would be appreciated. Thanks.

Xiaoyi