REPORT Procedure

COMPUTE Statement

Starts a compute block containing one or more programming statements that PROC REPORT executes as it builds the report.
Interaction: An ENDCOMP statement must mark the end of the group of statements in the compute block.
Note: A compute block can be associated with a report item or with a location (at the top or bottom of a report; at the top or bottom of a page; before or after a set of observations). You create a compute block with the COMPUTE window or with the COMPUTE statement. One form of the COMPUTE statement associates the compute block with a report item. Another form associates the compute block with a location. For a list of the SAS language elements that you can use in compute blocks, see The Contents of Compute Blocks.
Ordering the Rows in a Report

Using Aliases to Obtain Multiple Statistics for the Same Variable

Consolidating Multiple Observations into One Row of a Report

Creating a Column for Each Value of a Variable

Writing a Customized Summary on Each Page

Calculating Percentages

Storing Computed Variables as Part of a Data Set

Specifying Style Elements for ODS Output in Multiple Statements

Syntax

LINE specification(s);
. . . select SAS language elements . . .
ENDCOMP;
COMPUTE report-item </ type-specification>;
CALL DEFINE (column-id, 'attribute-name', value);
. . . select SAS language elements . . .
ENDCOMP;

Required Arguments

You must specify either a location or a report item in the COMPUTE statement.

location
determines where the compute block executes in relation to target.
AFTER
executes the compute block at a break in one of the following places:
  • immediately after the last row of a set of rows that have the same value for the variable that you specify as target or, if there is a default summary on that variable, immediately after the creation of the preliminary summary line. (See How PROC REPORT Builds a Report .)
  • except in Printer and RTF output, near the bottom of each page, immediately before any footnotes, if you specify _PAGE_ as target.
  • at the end of the report if you omit a target.
BEFORE
executes the compute block at a break in one of the following places:
  • immediately before the first row of a set of rows that have the same value for the variable that you specify as target or, if there is a default summary on that variable, immediately after the creation of the preliminary summary line. (See How PROC REPORT Builds a Report .)
  • except in Printer and RTF output, near the top of each page, between any titles and the column headings, if you specify _PAGE_ as target.
  • immediately before the first detail row if you omit a target.
Note:If a report contains more columns than will fit on a printed page, then PROC REPORT generates an additional page or pages to contain the remaining columns. In this case, when you specify _PAGE_ as target, the COMPUTE block does NOT re-execute for each of these additional pages; the COMPUTE block re-executes only after all columns have been printed.
report-item
specifies a data set variable, a computed variable, or a statistic to associate the compute block with. If you are working in the nonwindowing environment, then you must include the report item in the COLUMN statement. If the item is a computed variable, then you must include a DEFINE statement for it.
Note:The position of a computed variable is important. PROC REPORT assigns values to the columns in a row of a report from left to right. Consequently, you cannot base the calculation of a computed variable on any variable that appears to its right in the report.

Optional Arguments

STYLE<(location(s))>=<style-element-name><[style-attribute-specification(s)]>
specifies the style to use for the text that is created by any LINE statements in this compute block. See Using Style Elements in PROC REPORT for details.
Restriction:This option affects only the HTML, RTF, and Printer destinations.
Tip:FONT names that contain characters other than letters or underscores must be enclosed in quotation marks.
target
controls when the compute block executes. If you specify a location (BEFORE or AFTER) for the COMPUTE statement, then you can also specify target, which can be one of the following:
break-variable
is a group or order variable.
When you specify a break variable, PROC REPORT executes the statements in the compute block each time the value of the break variable changes.
_PAGE_ </ justification>
in monospace output destinations, causes the compute block to execute once for each page, either immediately after printing any titles or immediately before printing any footnotes. justification controls the placement of text and values. It can be one of the following:
CENTER
centers each line that the compute block writes.
LEFT
left-justifies each line that the compute block writes.
RIGHT
right-justifies each line that the compute block writes.
Default:CENTER
type-specification
specifies the type. (Optional) Also specifies the length of report-item. If the report item that is associated with a compute block is a computed variable, then PROC REPORT assumes that it is a numeric variable unless you use a type specification to specify that it is a character variable. A type specification has the form
CHARACTER <LENGTH=length>
where
CHARACTER
specifies that the computed variable is a character variable. If you do not specify a length, then the variable's length is 8.
Alias:CHAR
LENGTH=length
specifies the length of a computed character variable.
Default:8
Range:1 to 200
Interaction:If you specify a length, then you must use CHARACTER to indicate that the computed variable is a character variable.