SUPPORT / SAMPLES & SAS NOTES
 

Support

Usage Note 23207: I would like to generate a SAS data set from the FREQ procedure. How do I place the row, column and cell percentages from two-way, three-way or n-way tables into a SAS data set? I need to store the values in variables so I can calculate additional variables and parameters of interest from them.

DetailsAboutRate It

With Release 6.07 of the SAS System, the OUTPCT option in the TABLES statement creates the following additional variables in the output data set: PCT_COL, PCT_ROW, and PCT_TABL. The value of the PCT_TABL variable is the percentage of the two-way table frequency for n-way tables where n is greater than two.

See SAS Technical Report P-222: Changes and Enhancements to Base SAS Software, Release 6.07 for details.

Beginning in Version 7, you can use PROC FREQ and the Output Delivery System (ODS) to produce an output object called CROSSTABFREQS when tables have two or more dimensions. You can create an output data set from this object using the ODS OUTPUT statement containing the variables Row Percent, Col Percent, as well as _TABLE_. For additional information on ODS or the FREQ procedure, please refer to the SAS Procedures Guide in SAS OnlineDoc or in hard-copy format.

data test;
  input x y z;
cards;

1 2 3
1 2 4
1 3 4
1 3 3
2 3 4
2 3 4

; 

run; 

options missing=' ' nodate nonumber; 

title ' '; 

ods trace on; 

ods output crosstabfreqs=all; 

proc freq;
tables x*y*z / out=threeway outpct; 

run; 

proc print data=threeway noobs;
title 'Data Set Created for TABLES X*Y*Z and OUT='; 

run;

proc print data=all noobs;
title 'Data Set Created by ODS OUTPUT Statement';

run; 




PROC FREQ

Threeway

ODS



Operating System and Release Information

Product FamilyProductSystemSAS Release
ReportedFixed*
SAS SystemBase SASAlln/a
* For software releases that are not yet generally available, the Fixed Release is the software release in which the problem is planned to be fixed.