REPORT Procedure
COMPUTE Statement
Starts a compute block containing one or more programming
statements that PROC REPORT executes as it builds the report.
Syntax
LINE specification(s);
.
. . 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.
Writing a Customized Summary on Each Page
- 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.
Creating a Column for Each Value of a Variable
Optional Arguments
- STYLE<(location(s))>=<style-element-name><[style-attribute-specification(s)]>
-
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.
- 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>
- CHARACTER
-
specifies that the
computed variable is a character variable. If you do not specify
a length, then the variable's length is 8.
- 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.
Copyright © SAS Institute Inc. All rights reserved.