Previous Page | Next Page

The SORT Procedure

Example 1: Sorting by the Values of Multiple Variables


Procedure features:

PROC SORT statement option:

OUT=

BY statement

Other features:

PROC PRINT


This example


Program

 Note about code
options nodate pageno=1 linesize=80 pagesize=60;
 Note about code
data account;
   input Company $ 1-22 Debt 25-30 AccountNumber 33-36 
         Town $ 39-51;
   datalines;
Paul's Pizza             83.00  1019  Apex
World Wide Electronics  119.95  1122  Garner
Strickland Industries   657.22  1675  Morrisville
Ice Cream Delight       299.98  2310  Holly Springs
Watson Tabor Travel      37.95  3131  Apex
Boyd & Sons Accounting  312.49  4762  Garner
Bob's Beds              119.95  4998  Morrisville
Tina's Pet Shop          37.95  5108  Apex
Elway Piano and Organ    65.79  5217  Garner
Tim's Burger Stand      119.95  6335  Holly Springs
Peter's Auto Parts       65.79  7288  Apex
Deluxe Hardware         467.12  8941  Garner
Pauline's Antiques      302.05  9112  Morrisville
Apex Catering            37.95  9923  Apex
;
 Note about code
proc sort data=account out=bytown;
 Note about code
   by town company;
run;
 Note about code
proc print data=bytown;
 Note about code
   var company town debt accountnumber;
 Note about code
   title  'Customers with Past-Due Accounts';
   title2 'Listed Alphabetically within Town';
run;

Output

                        Customers with Past-Due Accounts                       1
                       Listed Alphabetically within Town

                                                                  Account
      Obs    Company                   Town              Debt      Number

        1    Apex Catering             Apex              37.95      9923 
        2    Paul's Pizza              Apex              83.00      1019 
        3    Peter's Auto Parts        Apex              65.79      7288 
        4    Tina's Pet Shop           Apex              37.95      5108 
        5    Watson Tabor Travel       Apex              37.95      3131 
        6    Boyd & Sons Accounting    Garner           312.49      4762 
        7    Deluxe Hardware           Garner           467.12      8941 
        8    Elway Piano and Organ     Garner            65.79      5217 
        9    World Wide Electronics    Garner           119.95      1122 
       10    Ice Cream Delight         Holly Springs    299.98      2310 
       11    Tim's Burger Stand        Holly Springs    119.95      6335 
       12    Bob's Beds                Morrisville      119.95      4998 
       13    Pauline's Antiques        Morrisville      302.05      9112 
       14    Strickland Industries     Morrisville      657.22      1675 

Previous Page | Next Page | Top of Page