Chapter Contents

Previous

Next
The SQL Procedure

Example 14: Matching Case Rows and Control Rows


Procedure features:
joined-table component
Tables: MATCH_11 , MATCH

This example uses a table that contains data for a case-control study. Each row contains information for a case or a control. To perform statistical analysis, you need a table with one row for each case-control pair. PROC SQL joins the table with itself in order to match the cases with their appropriate controls. After the rows are matched, differencing can be performed on the appropriate columns.

The input table MATCH_11 contains one row for each case and one row for each control. Pair contains a number that associates the case with its control. Low is 0 for the controls and 1 for the cases. The remaining columns contain information about the cases and controls.


Input Table
[HTML Output]  [Listing Output]


Program

options nodate pageno=1 linesize=80 pagesize=60;
 Note about code
proc sql;
   create table match as
      select
         one.Low,
         one.Pair,
         (one.lwt - two.lwt) as Lwt_d,
         (one.smoke - two.smoke) as Smoke_d,
         (one.ptd - two.ptd) as Ptd_d,
         (one.ht - two.ht) as Ht_d,
         (one.ui - two.ui) as UI_d
 Note about code
      from match_11 one, match_11 two
      where (one.pair=two.pair and one.low>two.low);



 Note about code
   title 'Differences for Cases and Controls';
   select *
      from match(obs=5);


Output
MATCH Table [HTML Output]
 [Listing Output]


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.