O'Reilly logo

Combining and Modifying SAS® Data Sets: Examples Second Edition by Michele M. Burlew

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Example 3.9 Generating Every Combination of Rows (Cartesian Product) between Tables

Goal

Combine two tables that have no common columns in order to produce every possible combination of rows.

Example Features

Featured StepPROC SQL
Featured Step Options and StatementsCartesian product
Related TechniqueDATA step, multiple SET statements, NOBS= and POINT= options

Input Tables

Table TRIAL_A has the identifiers for a group of patients who are participating in a clinical trial. Table TRIAL_TESTS contains the lab tests for this trial. There are no columns in common between the two tables.

          TRIAL_A

Obs  patientid  patientinits
 1     KPGY         AHB
 2     MWGM         DOH
 3     PQZU         LRH
 4     FQ82         HCI
 5     EYPS         MEF

       TRIAL_TESTS

Obs  testcode  testtype 1 L001 Cholesterol 2 L002 Glucose 3 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required