Beginning with SAS® 9.2, PROC FREQ has a crosstab table template, CrossTabFreqs. You can use this template to modify many aspects of the crosstab table.
The sample code on the Full Code tab changes the names of the default statistics to more meaningful names in the legend for all ODS destinations. The program also formats the percentage statistics (Percent, RowPercent, and ColPercent) with a percent (%) sign.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
Note: The default CrossTabFreqs table definition that is shipped with SAS is stored in the SASHELP.TMPLMST itemstore. You can return to that default definition by submitting a DELETE statement in PROC TEMPLATE.
/* Delete CrossTabFreqs to restore the original template */
proc template;
delete base.freq.crosstabfreqs;
run;
/* Create a picture format to display the % sign */
proc format;
picture pctfmt (round) other='009.9%';
run;
/* Modify the CrossTabFreqs table */
proc template;
define crosstabs Base.Freq.CrossTabFreqs;
cellvalue frequency percent rowpercent colpercent;
define frequency;
format=8.;
header='Count';
end;
define percent;
format=pctfmt.;
header='Overall %';
end;
define rowpercent;
format=pctfmt.;
header='Row %';
end;
define colpercent;
format=pctfmt.;
header='Col %';
end;
end;
run;
proc freq data=sashelp.class;
tables sex*age;
run;
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
The FREQ Procedure Count | Overall %| Row % | Col % | 11| 12| 13| 14| 15| 16| Total ---------+---------+---------+---------+---------+---------+---------+ F | 1 | 2 | 2 | 2 | 2 | 0 | 9 | 5.3% | 10.5% | 10.5% | 10.5% | 10.5% | 0.0% | 47.4% | 11.1% | 22.2% | 22.2% | 22.2% | 22.2% | 0.0% | | 50.0% | 40.0% | 66.7% | 50.0% | 50.0% | 0.0% | ---------+---------+---------+---------+---------+---------+---------+ M | 1 | 3 | 1 | 2 | 2 | 1 | 10 | 5.3% | 15.8% | 5.3% | 10.5% | 10.5% | 5.3% | 52.6% | 10.0% | 30.0% | 10.0% | 20.0% | 20.0% | 10.0% | | 50.0% | 60.0% | 33.3% | 50.0% | 50.0% | 100.0% | ---------+---------+---------+---------+---------+---------+---------+ Total 2 5 3 4 4 1 19 10.5% 26.3% 15.8% 21.1% 21.1% 5.3% 100.0%
Type: | Sample |
Date Modified: | 2015-05-28 10:51:38 |
Date Created: | 2003-07-01 10:59:58 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | Base SAS | z/OS | 9.2 TS1M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS1M0 | |||
Microsoft Windows XP 64-bit Edition | 9.2 TS1M0 | |||
Microsoft® Windows® for x64 | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Standard Edition | 9.2 TS1M0 | |||
Microsoft Windows XP Professional | 9.2 TS1M0 | |||
Windows Vista | 9.2 TS1M0 | |||
Windows Vista for x64 | 9.2 TS1M0 | |||
64-bit Enabled AIX | 9.2 TS1M0 | |||
64-bit Enabled HP-UX | 9.2 TS1M0 | |||
64-bit Enabled Solaris | 9.2 TS1M0 | |||
HP-UX IPF | 9.2 TS1M0 | |||
Linux | 9.2 TS1M0 | |||
Linux for x64 | 9.2 TS1M0 | |||
OpenVMS on HP Integrity | 9.2 TS1M0 | |||
Solaris for x64 | 9.2 TS1M0 |