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
Have you tried PROC FREQ?
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;
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
The odds ratio for a 2x2 table is defined as
OR = (n11*n22) / (n12*n21)
so the odds ratio for your example is 0.
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.
From a frequentist point of view, the estimate is zero. Are you looking for a Bayesian analysis?
@Xiaoyi wrote:
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.
It means that your sample size was too small for the event you're trying to observe.
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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.