Previous Page | Next Page

Producing Detail Reports with the PRINT Procedure

Review of SAS Tools


PROC PRINT Statements

PROC PRINT <DATA=SAS-data-set> <option(s)>;
BY variable(s);
FOOTNOTE<n> <'footnote'>;
FORMAT variable(s) format-name;
ID variable(s);
LABEL variable='label';
PAGEBY variable;
SUM variable(s);
SUMBY variable;
TITLE<n> <'title'>;
VAR variable(s);
WHERE where-expression;

PROC PRINT <DATA=SAS-data-set> <options>;

starts the procedure and, when used alone, shows all variables for all observations in the SAS-data-set in the report. Other statements, that are listed below, enable you to control what to report.

You can specify the following options in the PROC PRINT statement:

DATA=SAS-data-set

names the SAS data set that PROC PRINT uses. If you omit DATA=, then PROC PRINT uses the most recently created data set.

DOUBLE|D

writes a blank line between observations.

LABEL

uses variable labels instead of variable names as column headings for any variables that have labels defined. Variable labels appear only if you use the LABEL option or the SPLIT= option. You can specify labels in LABEL statements in the DATA step that creates the data set or in the PROC PRINT step. If you do not specify the LABEL option or if there is no label for a variable, then PROC PRINT uses the variable name.

N<="string-1" <"string-2">>

shows the number of observations in the data set, in BY groups, or both and optionally specifies explanatory text to include with the number.

NOOBS

suppresses the observation numbers in the output. This option is useful when you omit an ID statement and do not want to show the observation numbers.

SPLIT='split-character'

specifies the split character, which controls line breaks in column headers. PROC PRINT breaks a column heading when it reaches the split character and continues the header on the next line. The split character is not part of the column heading.

PROC PRINT uses variable labels only when you use the LABEL option or the SPLIT= option. It is not necessary to use both the LABEL and SPLIT= options because SPLIT= implies to use labels.

WIDTH=UNIFORM

uses each variable's formatted width as its column width on all pages. If the variable does not have a format that explicitly specifies a field width, then PROC PRINT uses the widest data value as the column width. Without this option, PROC PRINT fits as many variables and observations on a page as possible. Therefore, the report might contain a different number of columns on each page.

BY variable(s);

produces a separate section of the report for each BY group. The BY group is made up of the variables that you specify. When you use a BY statement, the procedure expects that the input data set is sorted by the variables.

FOOTNOTE<n> <'footnote'>;

specifies a footnote. The argument n is a number from 1 to 10 that immediately follows the word FOOTNOTE, with no intervening blank, and specifies the line number of the FOOTNOTE. The text of each footnote must be enclosed in single or double quotation marks. The maximum footnote length that is allowed depends on your operating environment and the value of the LINESIZE= system option. Refer to the SAS documentation for your operating environment for more information.

FORMAT variable(s) format-name;

enables you to report the value of a variable using a special pattern that you specify as format-name.

ID variable(s);

specifies one or more variables that PROC PRINT uses instead of observation numbers to identify observations in the report.

LABEL variable='label';

specifies to use labels for column headings. Variable names the variable to label, and label specifies a string of up to 256 characters, which includes blanks. The label must be enclosed in single or double quotation marks.

OBS='column-header'

specifies a column header for the column that identifies each observation by number.

PAGEBY variable;

causes PROC PRINT to begin a new page when the variable that you specify changes value or when any variable that you list before it in the BY statement changes value. You must use a BY statement with the PAGEBY statement.

SUM variable(s);

identifies the numeric variables to total in the report. You can specify a variable in the SUM statement and omit it in the VAR statement because PROC PRINT will add the variable to the VAR list. PROC PRINT ignores requests to total the BY and ID variables. In general, when you also use the BY statement, the SUM statement produces subtotals each time the value of a BY variable changes.

SUMBY variable;

limits the number of sums that appear in the report. PROC PRINT reports totals only when variable changes value or when any variable that is listed before it in the BY statement changes value. You must use a BY statement with the SUMBY statement.

TITLE<n> <'title'>;

specifies a title. The argument n is a number from 1 to 10 that immediately follows the word TITLE, with no intervening blank, and specifies the level of the TITLE. The text of each title must be enclosed in single or double quotation marks. The maximum title length that is allowed depends on your operating environment and the value of the LINESIZE= system option. Refer to the SAS documentation for your operating environment for more information.

VAR variable(s);

identifies one or more variables that appear in the report. The variables appear in the order that you list them in the VAR statement. If you omit the VAR statement, then all the variables appear in the report.

WHERE where-expression;

subsets the input data set by identifying certain conditions that each observation must meet before an observation is available for processing. Where-expression defines the condition. The condition is a valid arithmetic or logical expression that generally consists of a sequence of operands and operators.


PROC SORT Statements

PROC SORT <DATA=SAS-data-set>;
BY variable(s);

PROC SORT DATA=SAS-data-set;

sorts a SAS data set by the values of variables that you list in the BY statement.

BY variable(s);

specifies one or more variables by which PROC SORT sorts the observations. By default, PROC SORT arranges the data set by the values in ascending order (smallest value to largest).


SAS Macro Language

%LET macro-variable=value;

is a macro statement that defines a macro-variable and assigns it a value. The value that you define in the %LET statement is substituted for the macro-variable in output. To use the macro-variable in a program, include an ampersand (&) prefix before it.

SYSDATE9

is an automatic macro variable that contains the date that a SAS job or session began to execute. SYSDATE9 contains a SAS date value in the DATE9 format (ddmmmyyyy). The date displays a two-digit date, the first three letters of the month name, and a four-digit year. To use it in a program, you include an ampersand (&) prefix before SYSDATE9.

Previous Page | Next Page | Top of Page