Procedure features: |
PROC SORT statement option:
|
BY statement |
|
Other features: |
|
Data set: |
ACCOUNT
|
Interaction: |
The EQUALS option, which is the default,
must be in effect to ensure that the first observation for each BY group is
the one that is retained by the NODUPKEY option. If the NOEQUALS option has
been specified, then one observation for each BY group will still be retained
by the NODUPKEY option, but not necessarily the first observation.
|
In this example, PROC SORT creates an output data set
that contains only the first observation of each BY group. The NODUPKEY option
prevents an observation from being written to the output data set when its
BY value is identical to the BY value of the last observation written to the
output data set. The resulting report contains one observation for each town
where the businesses are located.
|
options nodate pageno=1 linesize=80 pagesize=60; |
|
proc sort data=account out=towns nodupkey; |
|
by town;
run; |
|
proc print data=towns; |
|
var town company debt accountnumber; |
|
title 'Towns of Customers with Past-Due Accounts';
run; |
|
Towns of Customers with Past-Due Accounts 1
Account
Obs Town Company Debt Number
1 Apex Paul's Pizza 83.00 1019
2 Garner World Wide Electronics 119.95 1122
3 Holly Springs Ice Cream Delight 299.98 2310
4 Morrisville Strickland Industries 657.22 1675
| |
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.