SAS OnlineTutor HomeFAQ PageSuggested Learning PathContents+Searchback||next

Creating Enhanced List and Summary Reports
Lesson Summary

This page contains


I. Text Summary

To go to the page where a task, programming feature, or concept was presented, select a link.


Creating a Default List Report
To create a default list report, you submit a basic PROC REPORT step. You can specify options to invoke the procedure in either a windowing or nonwindowing mode. By default, all observations and variables in the data set are printed, and variables appear in the order in which they occur in the data set.

Selecting Variables
To select and order the variables that appear in your list report, you can use the COLUMN statement.

Selecting Observations
To select rows for your report, you can use the WHERE statement as you do with many other SAS procedures.

Defining Variables
You can enhance your report by defining how each variable is used in the report. To describe how to use and display variables in your report, you use one or more DEFINE statements.

Defining Column Attributes
To assign a format to a specific report column, use the FORMAT= attribute in the DEFINE statement for that column. To specify a width for columns in your report, use the WIDTH= attribute in the DEFINE statement. To specify a different column spacing, use the SPACING= attribute in the DEFINE statement. To define a column heading, specify the heading text in quotation marks in the DEFINE statement. To control how words break in column headings, you can use a split character in the column label. For each variable that you define, you can specify the justification option CENTER, LEFT, or RIGHT in the DEFINE statement.

Enhancing the Heading's Appearance
To enhance headings in your report, you can use the HEADLINE option, which underlines all column headings and the spaces between them, and the HEADSKIP option, which writes a blank line beneath all column headings. These options have no effect on HTML output.

Defining Variable Usage
PROC REPORT uses each variable in one of six ways (DISPLAY, ORDER, GROUP, ACROSS, ANALYSIS, or COMPUTED). By default, PROC REPORT uses character variables as display variables, and it uses numeric variables as analysis variables, which are used to calculate the SUM statistic. You can define usage for variables in the DEFINE statement.

Variable Usage in PROC REPORT
Display
variables
do not affect the order of rows in the report. A report that contains one or more display variables has a detail row for each observation in the data set. Each detail row contains a value for each display variable. By default, PROC REPORT treats all character variables as display variables.
Order
variables
order the detail rows in a report according to their formatted values.
Group
variables
order the detail rows in a report according to their formatted values. If a report contains one or more group variables, PROC REPORT tries to consolidate into one row all observations from the data set that have a unique combination of values for all group variables.
Across
variables
are functionally similar to group variables; however, PROC REPORT displays the groups that it creates for an across variable horizontally rather than vertically.
Analysis
variables
are used to calculate a statistic. By default, PROC REPORT uses numeric variables as analysis variables, which are used to calculate the SUM statistic.
Computed
variables
are variables that you define for the report. They are not in the data set. You cannot change the usage of a computed variable. Computed variables can be either numeric or character variables.

Specifying Statistics
To associate a statistic with an analysis variable, specify it as an attribute in the DEFINE statement.


II. Syntax

To go to the page where a statement or option was presented, select a link.

PROC REPORT <DATA=SAS-data-set> <options>;
COLUMN variable(s);
DEFINE variable / <usage> <attribute(s)> <option(s)>
           <justification> <'column-heading'>;
COMPUTE computed-variable;
     DATA step statements;
ENDCOMP;
RUN;


III. Sample Program

     proc report data=clinic.diabetes nowd;
        column sex weight fastgluc postgluc glucrange;
        where age>40;
        define weight / format=comma6.2 spacing=4
                        'Average/Weight' width=7;
        define sex / order width=7 spacing=4 center
                     'Sex of/Patient';
        define fastgluc / 'Minimum/Fasting/Glucose';
        define postgluc / 'Maximum/Postprandial/Glucose'
                          width=12;
        define glucrange / computed 'Glucose/Range';
        compute glucrange;
           glucrange=postgluc.sum-fastgluc.sum;
        endcomp;
     run;

IV. Points to Remember
  • You can use PROC REPORT in either a windowing or nonwindowing mode.

  • You can use FORMAT statements with PROC REPORT, but the DEFINE statement enables you to specify more than one column attribute at a time.

  • For HTML output, the FORMAT= option cannot increase cell width beyond the width of cell values. The WIDTH= and SPACING= attributes, along with the HEADSKIP and HEADLINE options, have no effect on HTML output.

  • You can use the default slash as the split character, or you can specify a split character using the SPLIT= option in the PROC REPORT statement.

  • By default, PROC REPORT uses character variables as display variables and numeric variables as analysis variables, which are used to calculate the SUM statistic.

  • All of the variables in a summary report must be defined as group, analysis, across, or computed variables. If PROC REPORT can't create groups, it displays group variables as order variables.

  • You can't change the usage of a computed variable.

  • The position of a computed variable is important. You can't base the calculation of a computed variable on any variable that appears to its right in the report.

  back||next

Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.
Terms of Use & Legal Information | Privacy Statement