Procedure features: |
BREAK
statement options:
|
COMPUTE statement arguments:
|
with a computed variable as report-item |
|
BEFORE break-variable |
|
AFTER
break-variable with conditional logic |
|
BEFORE _PAGE_ | |
DEFINE statement options:
|
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 heading that identifies
the sector and the store's manager.
The heading 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.
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
libname proclib 'SAS-library'; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
options nodate pageno=1 linesize=64 pagesize=30
fmtsearch=(proclib); |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
proc report data=grocery nowd
headline headskip; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
title 'Sales for Individual Stores'; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
column sector manager department sales Profit; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
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](../../../../common/63294/HTML/default/images/snbut.gif) |
compute profit;
if department='np1' or department='np2'
then profit=0.4*sales.sum;
else profit=0.25*sales.sum;
endcomp; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
compute before _page_ / left;
line sector $sctrfmt. ' Sector';
line 'Store managed by ' manager $mgrfmt.;
line ' ';
line ' ';
line ' ';
endcomp; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
break after manager / ol summarize page; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
compute after manager; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
length text $ 35; |
![Note about code](../../../../common/63294/HTML/default/images/snbut.gif) |
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; |
Sales for Individual Stores 1
Northeast Sector
Store managed by Alomar
Department Sales Profit
------------------------------------
Canned $420.00 $168.00
Meat/Dairy $190.00 $47.50
Paper $90.00 $36.00
Produce $86.00 $21.50
----------- -----------
$786.00 $196.50
Sales are in the target region.
Sales for Individual Stores 2
Northeast Sector
Store managed by Andrews
Department Sales Profit
------------------------------------
Canned $420.00 $168.00
Meat/Dairy $300.00 $75.00
Paper $200.00 $80.00
Produce $125.00 $31.25
----------- -----------
$1,045.00 $261.25
Sales exceeded goal!
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.