Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
The FREQ Procedure

Inputting Frequency Counts

PROC FREQ can use either raw data or cell count data to produce frequency and crosstabulation tables. Raw data, also known as case-record data, report the data as one record for each subject or sample member. Cell count data report the data as a table, listing all possible combinations of data values along with the frequency counts. This way of presenting data often appears in published results.

The following DATA step statements store raw data in a SAS data set:

   data Raw;
      input Subject $ R C @@;
      datalines;
   01 1 1  02 1 1  03 1 1  04 1 1  05 1 1
   06 1 2  07 1 2  08 1 2  09 2 1  10 2 1
   11 2 1  12 2 1  13 2 2  14 2 2  14 2 2
   ;

You can store the same data as cell counts using the following DATA step statements:

   data CellCounts;
      input R C Count @@;
      datalines;
   1 1 5   1 2 3
   2 1 4   2 2 3
   ;

The variable R contains the values for the rows, and the variable C contains the values for the columns. The Count variable contains the cell count for each row and column combination.

Both the Raw data set and the CellCounts data set produce identical frequency counts, two-way tables, and statistics. With the CellCounts data set, you must use a WEIGHT statement to specify that the Count variable contains cell counts. For example, to create a two-way crosstabulation table, submit the following statements:

   proc freq data=CellCounts;
      weight Count;
      tables R*C;
   run;

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

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