Chapter Contents

Previous

Next
SORTEDBY=

SORTEDBY=



Specifies how the data set is currently sorted

Valid in: DATA step and PROC steps
Category: Data Set Control


Syntax
Syntax Description
Details
Comparisons
Examples
See Also

Syntax

SORTEDBY=by-clause </ collate-name> | _NULL_

Syntax Description

by-clause < / collate-name>
indicates how the data are currently sorted.
by-clause are the variables and options that you use in a BY statement in a PROC SORT step.
collate-name names the collating sequence that is used for the sort. By default, the collating sequence is that of your operating environment. A slash (/) must precede the collating sequence.

Operating Environment Information:   For details on collating sequences, see the SAS documentation for your operating environment.  [cautionend]

_NULL_
removes any existing sort information.


Details

SAS uses the sort information in these ways:

If you update a SAS file in a way that affects the validity of the sort, the sort information is removed. That is, if you change or add any values of the variables by which the data set is sorted, the sort information is removed.


Comparisons


Examples

This example uses the SORTEDBY= data set option to specify how the data are currently sorted. The data set ORDERS is sorted by PRIORITY and by the descending values of INDATE. Once the data set is created, the sort information is stored with it. These statements create the data set ORDERS and record the sort information:

libname mylib 'SAS-data-library';
options yearcutoff=1920;

data mylib.orders(sortedby=priority 
                  descending indate);
   input priority 1. +1 indate date7.
         +1 office $ code $;
   format indate date7.;
   datalines;
1 03may01 CH J8U
1 21mar01 LA M91
1 01dec00 FW L6R
1 27feb99 FW Q2A
2 15jan00 FW I9U
2 09jul99 CH P3Q
3 08apr99 CH H5T
3 31jan99 FW D2W
;

See Also

The CONTENTS Statement in "The DATASETS Procedure" in the SAS Procedures Guide
"The SORT Procedure" in the SAS Procedures Guide
"The SQL Procedure" in the SAS Procedures Guide


Chapter Contents

Previous

Next

Top of Page

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