Creating Summary Tables with the TABULATE Procedure |
If you design your summary table in advance, then you can save time and write simpler SAS code to produce the summary table. The basic steps of summary table design and construction are listed next. For a detailed step-by-step example of the design process, see PROC TABULATE by Example.
Prior to designing a summary table, it is important to understand that the summary table produces summary data wherever values for two or more variables intersect. The point of intersection is a cell. When values for two or more variables intersect, the variables are said to be crossed. The process of crossing variables to form intersections is called cross-tabulation. Variables in columns, rows, and pages can be crossed to produce summary data. The following summary table displays how two variables are crossed by highlighting a single value for each variable:
Here are the basic steps for designing and constructing a summary table:
Start with a question that you want to answer with a summary table.
Identify the variables necessary to answer your question.
See if any of the data sets that you are using already use the variables that you identified. If they do not, then you might be able to use the FORMAT procedure to reclassify the variable values in these data sets so that they produce the data that you need.
For example, you can apply a new format to values for a variable MONTH so that they become values for a variable QUARTER. To do this, assign the values representing the first three months to a value for quarter one, values representing the second set of three months to a value for quarter two, and so on.
If possible, use discrete variables rather than continuous variables for categories or headings. If you must use continuous variables, then it might be helpful to create categories. For example, you can group ages into categories such as ages 15-19, 20-35, 36-55, and 56-higher. This creates four categories rather than a possible 56+ categories. You can use PROC FORMAT to categorize the data.
Choose formats for the variables and the data that you want to display in your summary table. See if the data in your data sets is in a format that you can use. You might need to create new formats with PROC FORMAT, or copy the formats of variables from another data set so that the data will be formatted in the same way.
Review the data for anything that might cause discrepancies in your report.
Choose statistics that will help answer your question. For a complete list of statistics, see "Statistics Available in PROC TABULATE" in the Base SAS Procedures Guide.
Decide on the basic structure of the table. Use the variables that you have identified to determine the headings for the columns, rows, and pages. The values of the variables are the subheadings. Statistics are usually represented as subheadings, but are sometimes represented as headings. Crossing Variables is an example of a template for a very basic table.
Copyright © 2012 by SAS Institute Inc., Cary, NC, USA. All rights reserved.