Chapter Contents

Previous

Next
The SORT Procedure

Example 3: Displaying the First Observation of Each BY Group


Procedure features:
PROC SORT statement option:
NODUPKEY
BY statement
Other features:
PROC PRINT
Data set: ACCOUNT

In this example, PROC SORT creates an output data set that contains only the first observation of each BY group. The NODUPKEY option removes an observation from the output data set when its BY value is identical to the previous observation's BY value. The resulting report contains one observation for each town where the businesses are located.


Program

options nodate pageno=1 linesize=80 pagesize=60;

 Note about code
proc sort data=account out=towns nodupkey;
 Note about code
   by town;
run;
 Note about code
proc print data=towns;
 Note about code
   var town company debt accountnumber;
   title 'Towns of Customers with Past-Due Accounts';
run;


Output
The output data set contains only four observations, one for each town in the input data set. [HTML Output]
 [Listing Output]


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.