SAS OnlineTutor HomeFAQ PageSuggested Learning PathContents+Searchback||next

Creating Enhanced List and Summary Reports
Defining Variable Usage


Using Group Variables

Your list report is complete. But suppose you now want to create a summary report. That is, rather than a list of the mail, freight, and revenue for each flight, you want the total mail, freight, and revenue by flight number. Here is the summary report that you want to create:



Flight
Number
Flight
Origin
Flight
Destination
Mail Freight Revenue
219 LGA LON 2700 2513 $1,111,647.00
271 LGA PAR 5050 4421 $1,969,201.00
821 LGA LON 4438 4284 $2,077,907.00


To summarize your data using PROC REPORT, you can define one or more group variables. A group variable groups the detail rows in a report according to their formatted values. If a report contains one or more group variables, PROC REPORT consolidates into one row all observations from the data set that have a unique combination of values for all group variables.

To define a group variable, you specify the GROUP usage option in the DEFINE statement. Let's see how group variables affect your report.


Example

If you submit the following PROC REPORT step, with Flight defined as a group variable, you get the output shown below.


     proc report data=flights.europe nowd headline headskip;
        where dest in ('LON','PAR');
        column flight orig dest mail freight revenue;
        define revenue / format=dollar15.2;
        define flight / group 'Flight/Number' width=6 center;
        define orig / width=6 spacing=5 'Flight/Origin' center;
        define dest / width=11 spacing=5 'Flight/Destination'
                      center;
     run;

Flight
Number
Flight
Origin
Flight
Destination
Mail Freight Revenue
219
LGA
LON
331 376 $189,065.00
 
LGA
LON
485 267 $197,456.00
 
LGA
LON
388 298 $162,343.00
 
LGA
LON
421 356 $134,520.00
 
LGA
LON
447 299 $106,753.00
 
LGA
LON
356 547 $122,766.00
 
LGA
LON
272 370 $198,744.00
271
LGA
PAR
492 308 $156,804.00
 
LGA
PAR
366 498 $190,098.00
 
LGA
PAR
353 205 $166,470.00
 
LGA
PAR
366 279 $163,248.00
 
LGA
PAR
357 282 $170,766.00
 
LGA
PAR
415 463 $195,468.00
 
LGA
PAR
352 351 $123,456.00
 
LGA
PAR
492 308 $125,632.00
 
LGA
PAR
366 498 $128,972.00
 
LGA
PAR
353 205 $153,423.00
 
LGA
PAR
366 279 $133,345.00
 
LGA
PAR
357 282 $126,543.00
 
LGA
PAR
415 463 $134,976.00
821
LGA
LON
403 209 $150,634.00
 
LGA
LON
345 243 $150,634.00
 
LGA
LON
248 307 $193,930.00
 
LGA
LON
391 395 $167,772.00
 
LGA
LON
219 368 $183,106.00
 
LGA
LON
389 479 $169,576.00
 
LGA
LON
448 282 $143,561.00
 
LGA
LON
403 209 $170,766.00
 
LGA
LON
345 243 $129,560.00
 
LGA
LON
248 307 $196,736.00
 
LGA
LON
391 395 $125,344.00
 
LGA
LON
219 368 $166,543.00
 
LGA
LON
389 479 $129,745.00


But this output looks exactly like the list output in which Flight was an order variable. What happened?


back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement