BookmarkSubscribeRSS Feed
Jim_from_Canada
Calcite | Level 5

For a simple estimate of a risk ratio in a 2x2 table, FREQ is giving a value that is too large. In the example below, the Experimental group has 4 out of 336 subjects with the attribute (1.19%), and the Control group has 7 out of 355 (1.97%). That produces an estimated RR of 0.6037. Simple, right?

 

However, FREQ gives RR=0.8042. I can't figure how FREQ got that value!!!

 

I think this is a glitch, but I don't see a FIX for this. I'm running SAS 9.4 TS Level 1M4 on a X64_10PRO platform.

 

proc freq data=test;
   table Outcome * Treatment / relrisk ;
   run;

 

The FREQ Procedure

 

348
50.36
51.18
98.03
332
48.05
48.82
98.81
680
98.41
 
 
7
1.01
63.64
1.97
4
0.58
36.36
1.19
11
1.59
 
 
355
51.37
336
48.63
691
100.00

 

Statistics for Table of Outcome by tmt

Odds Ratio and Relative Risks Statistic Value

Odds Ratio 0.5990
Relative Risk (Col 1) 0.8042
Relative Risk (Col 2) 1.3426
95% Confidence Limits:
0.17372.0649
0.51141.2647
0.61212.9452

 

 

4 REPLIES 4
Rick_SAS
SAS Super FREQ

The documentation section "Odds Ratio and Relative Risks for 2x2 tables" defines the RELRISK computation.

"The relative risk is the ratio of the row 1 risk to the row 2 risk in a 2x2 table. The column 1 risk in row 1 is the proportion of row 1 observations that are classified in column 1, which can be expressed as"

p1 = n11 / n1 which for your table is 348/680

p2 = n21 / n2 which for your table is 7/11

The column 1 relative risk is computed as

R = p1/p2 which for your data is 0.8042, as reported.

 

Jim_from_Canada
Calcite | Level 5

Thanks for the reply. Probably worth a caution to users.

Jim_from_Canada
Calcite | Level 5

@Rick_SAS wrote:

The documentation section "Odds Ratio and Relative Risks for 2x2 tables" defines the RELRISK computation.

"The relative risk is the ratio of the row 1 risk to the row 2 risk in a 2x2 table. The column 1 risk in row 1 is the proportion of row 1 observations that are classified in column 1, which can be expressed as"

p1 = n11 / n1 which for your table is 348/680

p2 = n21 / n2 which for your table is 7/11

The column 1 relative risk is computed as

R = p1/p2 which for your data is 0.8042, as reported.

 


Thanks for the reply. It's probably worth a caution to users who prefer the RR to the OR.

Jim_from_Canada
Calcite | Level 5

If you want the correct answer for a risk ratio in SAS for a 2x2 table or a stratified 2x2 table using the FREQ procedure, you need to be careful with the configuration and the coding. We found this out the hard way!

 

For example, for a generic 2x2 table where the RR is the ratio of the Experimental to the Control proportion:

 

 

 

Outcome

 

 

Yes

No

Tmt

Experimental

4

332

 

Control

7

348

 

 

It is extremely important on the “order” of both the Treatment and Outcome label values.

For example, the data coding below for “tmt” and “outcome” will not give you what you want!

 

DATA tab2x2 ;
input tmt $ outcome $ freq ;
datalines ;
Exp Yes 4
Exp No  332
Ctl Yes 7
Ctl No  348
;

However, if you “order” the label values correctly, as shown below, for example:

 

 

 

Outcome

 

 

Yes

No

Tmt

Experimental

1, 1

1, 2

 

Control

2, 1

2, 2

 

DATA tab2x2;
input tmt $ outcome $ freq;
datalines;
1Exp 1Yes 4
1Exp 2No  332
2Ctl 1Yes 7
2Ctl 2No  348
;

This will give you the correct RR estimate.

 

Also, in the TABLE statement, the “tmt” factor must be listed before the “outcome” variable. For stratified tables, the stratum factor must be the first variable (e.g. stratum*tmt*outcome):

proc FREQ data=tab2x2 ;
TABLE tmt*outcome / relrisk ;
Weight freq ;
run ;

 

The output is shown below.

 

WRONG answers!

  

Frequency

Percent

Row Pct

Col Pct

Table of tmt by outcome

tmt

outcome

No

Yes

Total

Ctl

348

50.36

98.03

51.18

7

1.01

1.97

63.64

355

51.37

 

 

Exp

332

48.05

98.81

48.82

4

0.58

1.19

36.36

336

48.63

 

 

Total

680

98.41

11

1.59

691

100.00

 

Odds Ratio and Relative Risks

Statistic

Value

95% Confidence Limits

Odds Ratio

0.5990

0.1737

2.0649

Relative Risk (Column 1)

0.9921

0.9736

1.0110

Relative Risk (Column 2)

1.6563

0.4893

5.6069

 

 

RIGHT answer!

  

Frequency

Percent

Row Pct

Col Pct

Table of tmt by outcome

tmt

outcome

1Yes

2No

Total

1Exp

4

0.58

1.19

36.36

332

48.05

98.81

48.82

336

48.63

 

 

2Ctl

7

1.01

1.97

63.64

348

50.36

98.03

51.18

355

51.37

 

 

Total

11

1.59

680

98.41

691

100.00

 

Odds Ratio and Relative Risks

Statistic

Value

95% Confidence Limits

Odds Ratio

0.5990

0.1737

2.0649

Relative Risk (Column 1)

0.6037

0.1784

2.0437

Relative Risk (Column 2)

1.0080

0.9891

1.0272

 

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
  • 4 replies
  • 3288 views
  • 1 like
  • 2 in conversation