|
Chapter Contents |
Previous |
Next |
| The COMPUTAB Procedure |
This example consolidates product tables by region and region tables by corporate division. Output 9.4.1 shows the North Central and Northeast regional summaries for the Equipment division for the first quarter. Output 9.4.2 shows the profit summary for the Equipment division. Similar tables for the Publishing division are produced but not shown here.
data product;
input pcode div region month sold revenue recd cost;
datalines;
1 1 1 1 56 5600 29 2465
1 1 1 2 13 1300 30 2550
1 1 1 3 17 1700 65 5525
2 1 1 1 2 240 50 4900
2 1 1 2 82 9840 17 1666
more data lines
;
proc format;
value divfmt 1='Equipment'
2='Publishing';
value regfmt 1='North Central'
2='Northeast'
3='South'
4='West';
run;
proc sort data=product;
by div region pcode;
run;
title1 ' XYZ Development Corporation ';
title2 ' Corporate Headquarters: New York, NY ';
title3 ' Profit Summary ';
title4 ' ';
proc computab data=product sumonly;
by div region pcode;
sumby _total_ div region;
format div divfmt.;
format region regfmt.;
label div = 'DIVISION';
/* specify order of columns and column titles */
columns jan feb mar qtr1 / mtitle='- first quarter -' ' ' nozero;
columns apr may jun qtr2 / mtitle='- second quarter -' ' ' nozero;
columns jul aug sep qtr3 / mtitle='- third quarter -' ' ' nozero;
columns oct nov dec qtr4 / mtitle='- fourth quarter -' ' ' nozero;
column jan / ' ' 'January' '=';
column feb / ' ' 'February' '=';
column mar / ' ' 'March' '=';
column qtr1 / 'Quarter' 'Summary' '=';
column apr / ' ' 'April' '=' _page_;
column may / ' ' 'May' '=';
column jun / ' ' 'June' '=';
column qtr2 / 'Quarter' 'Summary' '=';
column jul / ' ' 'July' '=' _page_;
column aug / ' ' 'August' '=';
column sep / ' ' 'September' '=';
column qtr3 / 'Quarter' 'Summary' '=';
column oct / ' ' 'October' '=' _page_;
column nov / ' ' 'November' '=';
column dec / ' ' 'December' '=';
column qtr4 / 'Quarter' 'Summary' '=';
/* specify order of rows and row titles */
row sold / ' ' 'Number Sold' f=8.;
row revenue / ' ' 'Sales Revenue';
row recd / ' ' 'Number Received' f=8.;
row cost / ' ' 'Cost of' 'Items Received';
row profit / ' ' 'Profit' 'Within Period' ol;
row pctmarg / ' ' 'Profit Margin' dul;
/* select column for appropriate month */
_col_ = month + ceil( month / 3 ) - 1;
/* calculate quarterly summary columns */
colcalc:
qtr1 = jan + feb + mar;
qtr2 = apr + may + jun;
qtr3 = jul + aug + sep;
qtr4 = oct + nov + dec;
/* calculate profit rows */
rowcalc:
profit = revenue - cost;
if cost > 0 then pctmarg = profit / cost * 100;
run;
Output 9.4.1: Summary by Regions for the Equipment Division
|
|
|
|
Chapter Contents |
Previous |
Next |
Top |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.