![]() | ![]() | ![]() |
For one-way frequency tables, you can change these defaults by using PROC TEMPLATE to modify the table definition (or "template") that the Output Delivery System uses to display the table. The code below causes commas to be used for the Frequency and Cumulative Frequency columns, and uses only one decimal place to display the Percent and the Cumulative Percent.
ODS PATH RESET;
ODS PATH (PREPEND) WORK.Templat(UPDATE) ;
PROC TEMPLATE;
EDIT Base.Freq.OneWayList;
EDIT Frequency;
FORMAT = COMMA6.;
END;
EDIT CumFrequency;
FORMAT = COMMA6.;
END;
EDIT Percent;
FORMAT = 5.1;
END;
EDIT CumPercent;
FORMAT = 5.1;
END;
END;
RUN;
PROC FREQ DATA=SASHELP.Prdsale;
TABLES Division;
RUN;
|
The ODS PATH statement at the beginning causes the modified version of the Base.Freq.OneWayList table definition to be written into the WORK library, so that it will only be in effect for the duration of the SAS program or session.
Sometimes it is handy to get PROC FREQ output in "list" format even when two or more variables are involved. You can use the LIST option on the TABLE statement to tell PROC FREQ to use list format rather than presenting the results as a crosstabulation. For instance:
TABLES Division * Country / LIST; |
If you try this, however, you will notice that the changes you made in PROC TEMPLATE have no effect on this output. This is because ODS uses a different table definition, Base.Freq.List, for multiway tabulations in list format. You can change the defaults for this type of output by running PROC TEMPLATE again, specifying Base.Freq.List in the EDIT statement. Alternatively, you can include both EDIT blocks in the same PROC TEMPLATE run.
Modifying table definitions works fine, as long as a table definition is used to produce the output. While this is the case with the vast majority of SAS procedures, there are a few exceptions, and one of them is crosstabular output from PROC FREQ. (Other notable exceptions are the REPORT, PRINT, and TABULATE procedures.)
In Release 8.1, the SAS developers provided a partial solution to this problem by adding the FORMAT= option to the TABLES statement. When you are displaying your frequency output in crosstabular format, this statement allows you to specify a format that will be used to display the frequency, expected frequency, and deviation. For example:
TABLES Division * Country / FORMAT=COMMA6. ; |
Note: An excellent source of information is the PROC TEMPLATE FAQ and Concepts page, which can be found in the Base SAS Community. This, in fact, is where I first learned how to change the output format for one-way frequencies (tip D2).
![]()
Contact information
The author may be reached at:
Mike Rhoads
Westat
1650 Research Blvd.
Rockville, MD 20850
RhoadsM1@Westat.com
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.
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.
| Type: | Sample |
| Topic: | SAS Reference ==> Procedures ==> FREQ SAS Reference ==> ODS (Output Delivery System) Analytics ==> Nonparametric Analysis Analytics ==> Longitudinal Analysis Analytics ==> Exact Methods Non SAS Authors ==> Mike Rhoads Analytics ==> Descriptive Statistics Analytics ==> Categorical Data Analysis |
| Date Modified: | 2009-10-26 08:55:32 |
| Date Created: | 2004-10-11 14:47:27 |
| Product Family | Product | Host | SAS Release | |
| Starting | Ending | |||
| SAS System | Base SAS | All | n/a | n/a |



