SAS Component Language Dictionary |
Category: | SAS Table |
Syntax | |
Details | |
Example |
Syntax |
sysrc=SORT(table-id,col-list-1<. . .col-list-4>); |
contains the return code for the operation:
0 | |
0 |
contains the identifier that was assigned when the table was opened. The table must be open in UPDATE mode. If table-id is invalid, the program halts.
is one to four quoted strings of columns or options, separated by blanks. For a list of options, the first character in the list must be a forward slash (/). Columns and options cannot be mixed in the same list.
Details |
SORT uses the sorting program that SAS supports on your operating system. If a column list contains more than one column, the table is sorted by those columns in the order in which they are specified.
You can use the following options for col-list, depending on your operating system:
DATECOPY DIAG EQUALS FORCE LEAVE LIST MESSAGE NODUPKEY NODUPLICATES NOEQUALS OUT REVERSE SORTSEQ=ASCII|EBCDIC|DANISH|FINNISH |NATIONAL|NORWEGIAN|SWEDISH SORTSIZE SORTWKNO TAGSORT TRANTAB
SAS views cannot be sorted in place. To sort views, you must specify an output SAS table.
If a SAS table is already in sorted order, then you must use the FORCE option.
Note: Unless you specify the FORCE option, the SORT function and PROC SORT do not sort and replace an indexed SAS table, because sorting destroys indexes for the table.
Example |
Use the SORT function with the options NODUPKEY, NODUPLICATES, and TAGSORT to sort the SAS table MYDATA by column A in ascending order and by column B in descending order:
rc=sort(mydataid,'a descending b', '/ nodupkey noduplicates tagsort');
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.