Chapter Contents

Previous

Next
The REPORT Procedure

Example 9: Writing a Customized Summary on Each Page


Procedure features:
BREAK statement options:
OL
PAGE
SUMMARIZE
COMPUTE statement arguments:
with a computed variable as report-item
BEFORE break-variable
AFTER break-variable with conditional logic
BEFORE _PAGE_
DEFINE statement options:
NOPRINT
LINE statement:
pointer controls
quoted text
repeating a character string
variable values and formats
Data set: GROCERY
Formats: $SCTRFMT., $MGRFMT., and $DEPTFMT.

The report in this example displays a record of one day's sales for each store. The rows are arranged so that all the information about one store is together, and the information for each store begins on a new page. Some variables appear in columns. Others appear only in the page header that identifies the sector and the store's manager.

The header that appears at the top of each page is created with the _PAGE_ argument in the COMPUTE statement.

Profit is a computed variable based on the value of Sales and Department.

The text that appears at the bottom of the page depends on the total of Sales for the store. Only the first two pages of the report appear here.





Program

libname proclib 'SAS-data-library';
options nodate pageno=1 linesize=64 pagesize=30
        fmtsearch=(proclib);
 Note about code
proc report data=grocery nowd
            headline headskip;

 Note about code
   title 'Sales for Individual Stores';
 Note about code
   column sector manager department sales Profit;
 Note about code
   define sector / group noprint;
   define manager / group noprint;
   define profit / computed format=dollar11.2;
   define sales / analysis sum format=dollar11.2;
   define department / group format=$deptfmt.;
 Note about code
   compute profit;
      if department='np1' or department='np2' 
         then profit=0.4*sales.sum;
      else profit=0.25*sales.sum;
   endcomp;
 Note about code
    compute before _page_ / left;
      line sector $sctrfmt. ' Sector';
      line 'Store managed by ' manager $mgrfmt.;
      line ' ';
      line ' ';
      line ' ';
   endcomp;
 Note about code
   break after manager / ol summarize page;


 Note about code
   compute after manager;
 Note about code
      length text $ 35;
 Note about code
      if sales.sum lt 500 then
         text='Sales are below the target region.';
      else if sales.sum ge 500 and sales.sum lt 1000 then
         text='Sales are in the target region.';
      else if sales.sum ge 1000 then
         text='Sales exceeded goal!';
      line ' ';
      line text $35.;
   endcomp;
   run;


Output
[HTML Output]  [Listing Output]


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.