SAS OnlineTutor HomeFAQ PageSuggested Learning PathContents+Searchback||next

Creating Enhanced List and Summary Reports
Defining Variable Usage


Using Order Variables

An order variable orders the detail rows in a report according to their formatted values. For example, suppose you want to see values in your list report ordered by flight number. To use Flight as an order variable, you specify the ORDER usage option in the DEFINE statement, as 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 / order 'Flight/Number' width=6 center;
        define orig / width=6 spacing=5 'Flight/Origin' center;
        define dest / width=11 spacing=5 'Flight/Destination' 
center; run;

This is your ordered output. Notice that PROC REPORT displays only the first occurrence of each value of an order variable in a set of rows that have the same value for all order variables.



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


By default, the order is ascending, but you can change it with the DESCENDING option in the DEFINE statement:


     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 / order descending 'Flight/Number' width=6
                        center;
        define orig / width=6 spacing=5 'Flight/Origin' center;
        define dest / width=11 spacing=5 'Flight/Destination'
                      center;
     run;
back||next


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

Terms of Use & Legal Information | Privacy Statement