Sorts the items in an SCL list by value or by name
- contains the identifier of the sorted list.
The value passed as list-id is returned unless
there is an error. The value 0 means out of memory.
- is the identifier of the list to sort. An
invalid list-id produces an error condition.
Type: Numeric or
- specify how the sort operation is performed.
Multiple options can be specified, separated by blanks. Each option can be
abbreviated to a unique substring. The substring can be as short as the first
character for all options except
'NODUP', which may be abbreviated to two characters,
Later keywords override previous keywords.
- Sort the list in ascending order. (This
is a default.)
- Sort the list in descending order.
- Ignore case when comparing string values.
Case is always ignored when sorting by name, because names are always converted
- Sort the list by item name. Unnamed items
appear before named items in an ascending sort.
- Delete duplicate items when sorting. All
but the first item in the sort range that have the same value (or the same
name, if sorting by name) are deleted. The default is not to delete duplicates.
- Obey case when comparing string values.
This is the default when sorting by value.
- Sort the list by item value. In an ascending
sort, character items precede list identifiers, which precede numeric missing
values, followed by non-missing numeric values. (This is a default.)
- specifies the starting position for sorting
a range of items in the list. By default, start-index
is 1 (the first item). If start-index is positive,
then the range begins start-index items from
the beginning of the list. If start-index is
negative, then the range begins at the item specified by ABS(start-index) items from the end of the list. An error condition
results if the absolute value of start-index
is zero or if it is greater than the number of items in the list.
- specifies the number of items in the list
to sort. The default is all items between start-index
and the opposite end of the list. To explicitly specify all items, specify -1.
SORTLIST does not make a copy of the list before it
is sorted. The list is modified in place.
Sublists that are contained in the sorted list are not
When you specify the
'NOHONORCASE' options, the character list
items or names that are spelled the same but differ only in case are considered
duplicates, and all but the first occurrence are removed from the sorted list.
An error occurs if the list has the NOUPDATE attribute
or if an item to be removed has the NODELETE attribute, if NODUP is specified.
Use HASATTR to check the attributes of a list or item. To change attributes,
- Sort the first 10 items in a list in descending
- Sort the last 16 items in a list in ascending
- Sort the second ten items in a list in ascending
name order, deleting items that have duplicate names:
list=sortlist(list,'NODUP ASCENDING NAME',11,10);
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.