SAS Data Set Options |
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_ |
indicates how the data is currently sorted.
Details |
SAS determines whether a data set is already sorted by the key variable or variables in ascending order by checking the sort indicator. The sort indicator is stored in the data set descriptor information and is set from a previous sort. For detailed information about how the sort indicator is used and how it improves performance, see The Sort Indicator and the SORTVALIDATE System Option .
The following example of the CONTENTS procedure Sort Information section containing the Validated attribute set to NO, indicates that the data set was sorted using the SORTEDBY= data set option.
Sort Information Sortedby var1 Validated NO Character Set ANSI
Comparisons |
Use the CONTENTS statement in the DATASETS procedure to see how a data set is sorted.
The SORTEDBY= option indicates how the data is sorted, but does not cause a data set to be sorted.
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 indicator is stored with it. These statements create the data set ORDERS and record the sort indicator:
libname mylib 'SAS-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 Base SAS Procedures Guide | |
The SORT Procedure in Base SAS Procedures Guide | |
The SQL Procedure in Base SAS Procedures Guide |
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.