Chapter Contents |
Previous |
Next |
The REPORT Procedure |
Laying Out a Report |
Once you understand the layout of the report, use the COLUMN and DEFINE statements in PROC REPORT to construct the layout.
The COLUMN statement lists the items that appear in the columns of the report, describes the arrangement of the columns, and defines headers that span multiple columns. A report item can be
Omit the COLUMN statement if you want to include all variables in the input data set in the same order as they occur in the data set.
Note: If you start PROC REPORT in the windowing environment without
the COLUMN statement, the initial report includes only as many variables as
will fit on one page.
The DEFINE statement (or, in the windowing environment, the DEFINITION
window) defines the characteristics of an item in the report. These characteristics
include how PROC REPORT uses the item in the report, the text of the column
header, and the format to use to display values.
DISPLAY | ORDER | ACROSS | GROUP | ANALYSIS |
A report can
contain variables that are not in the input data set. These
variables must have a usage of COMPUTED.
Featured in: | Selecting Variables for a Report |
If the report contains multiple order variables, PROC REPORT establishes the order of the detail rows by sorting these variables from left to right in the report. PROC REPORT does not repeat the value of an order variable from one row to the next if the value does not change.
Featured in: | Ordering the Rows in a Report |
If you are familiar with procedures that use class variables, you will see that across variables are class variables that are used in the column dimension.
Featured in: | Creating a Column for Each Value of a Variable |
When PROC REPORT creates groups, it orders the detail rows by the ascending, formatted values of the group variable. You can change the default order with ORDER= and DESCENDING in the DEFINE statement or with the DEFINITION window.
If the report contains multiple group variables, the REPORT procedure establishes the order of the detail rows by sorting these variables from left to right in the report. PROC REPORT does not repeat the values of a group variable from one row to the next if the value does not change.
If you are familiar with procedures that use class variables, you will see that group variables are class variables that are used in the row dimension.
Note: You cannot always create groups. PROC REPORT cannot consolidate
observations into groups if the report contains any order variables or any
display variables that do not have one or more statistics associated with
them (see COLUMN Statement ).
In the windowing environment, if PROC REPORT cannot immediately create groups,
it changes all display and order variables to group variables so that it can
create the group variable that you requested. In the nonwindowing environment,
it returns to the SAS log a message that explains why it could not create
groups. Instead, it creates a detail report that displays group variables
the same way as it displays order variables. Even if PROC REPORT creates a
detail report, the variables that you defined as group variables retain that
usage in their definitions.
The value of an analysis variable depends on where it appears in the report:
In the windowing environment, you add a computed variable to a report from the COMPUTED VAR window.
In the nonwindowing environment, you add a computed variable by
Featured in: | Creating a Column for Each Value of a Variable , Calculating Percentages , and Storing Computed Variables as Part of a Data Set |
Several items can collectively define the contents of a column in a report. For instance, in Stacking Department and Sales , the values that appear in the third and fourth columns are collectively determined by Sales, an analysis variable, and by Department, an across variable. You create this kind of report with the COLUMN statement or, in the windowing environment, by placing report items above or below each other. This is called stacking items in the report because each item generates a header, and the headers are stacked one above the other.
When you use multiple items to define the contents of a column, at most one of the following can be in a column:
More than one of these items in a column creates a conflict for PROC REPORT about which values to display.
Report Items That Can Share Columns shows which report items can share a column.
Note: You
cannot stack group or order variables with other report items.
Display | Analysis | Order | Group | Computed | Across | Statistic | |
---|---|---|---|---|---|---|---|
Display | X* | X | |||||
Analysis | X | X | |||||
Order | |||||||
Group | |||||||
Computed variable | X | ||||||
Across | X* | X | X | X | X | ||
Statistic | X | X | X | ||||
*When a display variable and an across variable share a column, the report must also contain another variable that is not in the same column. |
Note: The values in a column occupied only by an across variable are
frequency counts.
N | CSS |
NMISS | STDERR |
MEAN | CV |
STD | T |
MIN | PRT |
MAX | VAR |
RANGE | SUMWGT |
SUM | PCTN |
USS | PCTSUM |
Every statistic except N must be associated with a variable. You associate a statistic with a variable either by placing the statistic above or below a numeric display variable or by specifying the statistic as a usage option in the DEFINE statement or in the DEFINITION window for an analysis variable.
You can place N anywhere because it is the number of observations in the input data set that contributes to the value in a cell of the report. The value of N does not depend on a particular variable.
For definitions of these statistics, see Keywords and Formulas .
Note: If you use the MISSING option in the PROC REPORT statement, N
includes observations with missing group, order, or across variables.
Using Compute Blocks |
Note: When you use the COMPUTE statement, you do not
have to use a corresponding
BREAK or RBREAK statement. (See Ordering the Rows in a Report , which uses COMPUTE AFTER but does
not use the RBREAK statement). Use these statements only when you want to
implement one or more BREAK statement or RBREAK statement options (see Writing a Customized Summary on Each Page ,
which uses both COMPUTE AFTER MANAGER and BREAK AFTER MANAGER.
A compute block that is associated with a location can write a customized summary.
In addition, all compute blocks can use SAS language elements to perform
calculations (see The Contents of Compute Blocks ). A PROC REPORT step can contain multiple
compute blocks.
assignment | LENGTH |
CALL | LINK |
DO (all forms) | RETURN |
END | SELECT |
GO TO | sum |
IF-THEN/ELSE |
For information about SAS language elements see the appropriate section in SAS Language Reference: Dictionary.
Within a compute block, you can also use these PROC REPORT features:
variable-name.statistic |
_Cn_ |
Note: Even though the columns that you define with NOPRINT and NOZERO
do not appear in the report, you must count them when you are referencing
columns by number. See the discussion of NOPRINT and
NOZERO .
The following table shows how to use each type of reference in a compute block.
If the variable that you reference is this type... | Then refer to it by... | For example... | |
---|---|---|---|
group | name* |
Department | |
order | name* |
Department | |
computed | name* |
Department | |
display | name* |
Department | |
display sharing a column with a statistic | a compound name* |
Sales.sum | |
analysis | a compound name* |
Sales.mean | |
any type sharing a column with an across variable | column number ** | _c3_ | |
*If the variable has an alias, you must reference it with the alias. | |||
**Even if the variable has an alias, you must reference it by column number. |
Featured in: | Using Aliases to Obtain Multiple Statistics for the Same Variable , which references analysis variables by their aliases; Creating a Column for Each Value of a Variable , which references variables by column number; and Calculating Percentages , which references group variables and computed variables by name. |
Note: PROC REPORT recalculates computed variables at breaks. For details
on compute block processing see How PROC REPORT Builds a Report .
Using Break Lines |
Break lines can contain
Default summaries are produced with the BREAK statement, the RBREAK statement, or the BREAK window. You can use default summaries to visually separate parts of the report, to summarize information for numeric variables, or both. Options provide some control over the appearance of the break lines, but if you choose to summarize numeric variables, you have no control over the content and the placement of the summary information. (A break line that summarizes information is a summary line.)
Customized summaries are produced in a compute block. You can control
both the appearance and content of a customized summary, but you must write
the code to do so.
If you define a
customized summary for the same location, customized
break lines appear after underlining or double underlining.
RBREAK
if the current line is part
of a break at the beginning or end of the report.
Using Style Elements in PROC REPORT |
You specify style elements for PROC REPORT with the STYLE= option. Using the STYLE= Option in PROC REPORT shows where you can use this option. Specifications on a statement other than the PROC REPORT statement override the same specification in the PROC REPORT statement. However, any style attributes that you specify in the PROC REPORT statement and do not override in another statement are inherited. For instance, if you specify a blue background and a white foreground for all column headers in the PROC REPORT statement, and you specify a gray background for the column headers of a variable in the DEFINE statement, the background for that particular column header is gray, and the foreground is white (as specified in the PROC REPORT statement).
Detailed information about STYLE= is provided in the documentation for individual statements.
To set the style element for | Use STYLE= in this statement |
---|---|
The report as a whole, including attributes of the table itself (like the spacing between cells) as well as style elements for column headers, cells, default summaries, customized summaries, and individual cells defined by CALL DEFINE statements | PROC REPORT |
Column headers and cells for a particular variable | DEFINE |
Default summary lines | BREAK RBREAK |
Customized summary lines | COMPUTE (with a location and LINE statements) |
Individual cells of the report | CALL DEFINE |
Printing a Report |
Note: Forms are available only when you run SAS from a windowing
environment.
Operating Environment Information: Printing
is
implemented differently in different operating environments.
For information related to printing, consult SAS Language Reference: Concepts. Additional information
may be available in the SAS documentation for your operating environment.
You can print the output file directly or use PROC PRINTTO to redirect the output to another file. In either case, no form is used, but carriage control characters are written if the destination is a print file.
Use operating environment commands to send the file to the printer.
PROC PRINTTO does not use a form, but it does write carriage control characters if you are writing to a print file.
Storing and Reusing a Report Definition |
In the windowing environment, you can save the definition of the current report by selecting
File | Save Report |
You can use a report definition to create an identically structured report for any SAS data set that contains variables with the same names as the ones used in the report definition. Use the REPORT= option in the PROC REPORT statement to load a report definition when you start PROC REPORT. In the windowing environment, load a report definition from the LOAD REPORT window by selecting
File | Open Report |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.