Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
The CORRESP Procedure

Creating a Data Set Containing the Crosstabulation

The CORRESP procedure can read or create a contingency or Burt table. PROC CORRESP is generally more efficient with VAR statement input than with TABLES statement input. TABLES statement input requires that the table be created from raw categorical variables, whereas the VAR statement is used to read an existing table. If PROC CORRESP runs out of memory, it may be possible to use some other method to create the table and then use VAR statement input with PROC CORRESP.

The following example uses the CORRESP, FREQ, and TRANSPOSE procedures to create rectangular tables from a SAS data set WORK.A that contains the categorical variables V1 -V5. The Burt table examples assume that no categorical variable has a value found in any of the other categorical variables (that is, that each row and column label is unique).

You can use PROC CORRESP and ODS to create a rectangular two-way contingency table from two categorical variables.

   proc corresp data=a observed short;
      ods listing close;
      ods output Observed=Obs(drop=Sum where=(Label ne 'Sum'));
      tables v1, v2;
   run;

   ods listing;

You can use PROC FREQ and PROC TRANSPOSE to create a rectangular two-way contingency table from two categorical variables.

   proc freq data=a;
      tables v1 * v2 / sparse noprint out=freqs;
   run;

   proc transpose data=freqs out=rfreqs;
      id  v2;
      var count;
      by  v1;
   run;

You can use PROC CORRESP and ODS to create a Burt table from five categorical variables.

   proc corresp data=a observed short mca;
      ods listing close;
      ods output Burt=Obs;
      tables v1-v5;
   run;

   ods listing;

You can use a DATA step, PROC FREQ, and PROC TRANSPOSE to create a Burt table from five categorical variables.

   data b;
      set a;
      array v[5] $ v1-v5;
      do i = 1 to 5;
         row = v[i];
         do j = 1 to 5;
            column = v[j];
            output;
            end;
         end;
      keep row column;
   run;

   proc freq data=b;
      tables row * column / sparse  noprint out=freqs;
   run;

   proc transpose data=freqs out=rfreqs;
      id  column;
      var count;
      by  row;
   run;

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

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