BookmarkSubscribeRSS Feed
Xiaoyi
Obsidian | Level 7

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

8 REPLIES 8
Reeza
Super User

Have you tried PROC FREQ? 

Reeza
Super User

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;
Xiaoyi
Obsidian | Level 7

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

Rick_SAS
SAS Super FREQ

The odds ratio for a 2x2 table is defined as

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

so the odds ratio for your example is 0.

Xiaoyi
Obsidian | Level 7

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. 

Rick_SAS
SAS Super FREQ

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

Reeza
Super User

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

Xiaoyi
Obsidian | Level 7

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

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 1531 views
  • 0 likes
  • 3 in conversation