BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
zhawasli1
Obsidian | Level 7

Is it even possible to do in sas studio?

If I know all the numbers in the two by two table of a case-control study.  Could sas calculate the percentages of each number and the odds ratio?  Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Just type the counts in. Make sure you also create the other two variables.

data summary;
  length group result $8 count 8;
  do group='case','control';
    do result='good','bad';
      input count @@;
      output;
    end;
  end;
cards;
10 50 49 11 
;

proc freq;
  tables group*result / cmh ;
  weight count;
run;
The FREQ Procedure

Table of group by result

group     result

Frequency|
Percent  |
Row Pct  |
Col Pct  |bad     |good    |  Total
---------+--------+--------+
case     |     50 |     10 |     60
         |  41.67 |   8.33 |  50.00
         |  83.33 |  16.67 |
         |  81.97 |  16.95 |
---------+--------+--------+
control  |     11 |     49 |     60
         |   9.17 |  40.83 |  50.00
         |  18.33 |  81.67 |
         |  18.03 |  83.05 |
---------+--------+--------+
Total          61       59      120
            50.83    49.17   100.00

The FREQ Procedure

Summary Statistics for group by result

  Cochran-Mantel-Haenszel Statistics (Based on Table Scores)

Statistic    Alternative Hypothesis    DF       Value      Prob
---------------------------------------------------------------
    1        Nonzero Correlation        1     50.2915    <.0001
    2        Row Mean Scores Differ     1     50.2915    <.0001
    3        General Association        1     50.2915    <.0001


                        Common Odds Ratio and Relative Risks

Statistic                   Method                  Value       95% Confidence Limits
-------------------------------------------------------------------------------------
Odds Ratio                  Mantel-Haenszel       22.2727        8.6773       57.1693
                            Logit                 22.2727        8.6773       57.1693

Relative Risk (Column 1)    Mantel-Haenszel        4.5455        2.6333        7.8462
                            Logit                  4.5455        2.6333        7.8462

Relative Risk (Column 2)    Mantel-Haenszel        0.2041        0.1145        0.3639
                            Logit                  0.2041        0.1145        0.3639


Total Sample Size = 120

View solution in original post

6 REPLIES 6
Haris
Lapis Lazuli | Level 10

You will need to create a small dataset with three columns: 1. columns values 2. row values, 3 cell counts.  For a 2x2 table you will have four rows with all possible combinations of row and column values: 00, 01, 10, 11.  Then run PROC FREQ with WEIGHT as cell counts.  That's it.

Tom
Super User Tom
Super User

Just type the counts in. Make sure you also create the other two variables.

data summary;
  length group result $8 count 8;
  do group='case','control';
    do result='good','bad';
      input count @@;
      output;
    end;
  end;
cards;
10 50 49 11 
;

proc freq;
  tables group*result / cmh ;
  weight count;
run;
The FREQ Procedure

Table of group by result

group     result

Frequency|
Percent  |
Row Pct  |
Col Pct  |bad     |good    |  Total
---------+--------+--------+
case     |     50 |     10 |     60
         |  41.67 |   8.33 |  50.00
         |  83.33 |  16.67 |
         |  81.97 |  16.95 |
---------+--------+--------+
control  |     11 |     49 |     60
         |   9.17 |  40.83 |  50.00
         |  18.33 |  81.67 |
         |  18.03 |  83.05 |
---------+--------+--------+
Total          61       59      120
            50.83    49.17   100.00

The FREQ Procedure

Summary Statistics for group by result

  Cochran-Mantel-Haenszel Statistics (Based on Table Scores)

Statistic    Alternative Hypothesis    DF       Value      Prob
---------------------------------------------------------------
    1        Nonzero Correlation        1     50.2915    <.0001
    2        Row Mean Scores Differ     1     50.2915    <.0001
    3        General Association        1     50.2915    <.0001


                        Common Odds Ratio and Relative Risks

Statistic                   Method                  Value       95% Confidence Limits
-------------------------------------------------------------------------------------
Odds Ratio                  Mantel-Haenszel       22.2727        8.6773       57.1693
                            Logit                 22.2727        8.6773       57.1693

Relative Risk (Column 1)    Mantel-Haenszel        4.5455        2.6333        7.8462
                            Logit                  4.5455        2.6333        7.8462

Relative Risk (Column 2)    Mantel-Haenszel        0.2041        0.1145        0.3639
                            Logit                  0.2041        0.1145        0.3639


Total Sample Size = 120
zhawasli1
Obsidian | Level 7
If I have the frequency for each cell, does that mean I type it in SAS in the two by two table?
zhawasli1
Obsidian | Level 7

The FREQ Procedure

Frequency
Percent
Row Pct
Col Pct
Table of group by result
group result
east west Total
notuberc
141
42.73
50.36
77.90
139
42.12
49.64
93.29
280
84.85


tubercul
40
12.12
80.00
22.10
10
3.03
20.00
6.71
50
15.15


Total
181
54.85
149
45.15
330
100.00
Summary Statistics for group by result

Cochran-Mantel-Haenszel Statistics (Based on Table Scores)
Statistic Alternative Hypothesis DF Value Prob
1 Nonzero Correlation 1 15.0072 0.0001
2 Row Mean Scores Differ 1 15.0072 0.0001
3 General Association 1 15.0072 0.0001
Common Odds Ratio and Relative Risks
Statistic Method Value 95% Confidence Limits
Odds Ratio Mantel-Haenszel 0.2536 0.1220 0.5270
Logit 0.2536 0.1220 0.5270
Relative Risk (Column 1) Mantel-Haenszel 0.6295 0.5253 0.7543
Logit 0.6295 0.5253 0.7543
Relative Risk (Column 2) Mantel-Haenszel 2.4821 1.4082 4.3750
Logit 2.4821 1.4082 4.3750
Total Sample Size = 330
zhawasli1
Obsidian | Level 7
Also, why can't I copy and paste your data entry and proc onto my sas studio?

SAS Innovate 2025: Call for Content

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!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 916 views
  • 0 likes
  • 3 in conversation