space
Previous Page | Next Page

ACCESS Procedure Reference

ordering-clause in SYSTEM 2000


Using the ordering-clause (SYSTEM 2000)

When you define a view descriptor, you can also include a SYSTEM 2000 ordering-clause to specify the order of the data. You can use only the items selected for the view descriptor. Without an ordering-clause or a BY statement in SAS, the order of the data is determined by SYSTEM 2000.

A BY statement in SAS automatically issues an ordering-clause to SYSTEM 2000. If a view descriptor already contains an ordering-clause, the BY statement overrides the ordering-clause for that program except when the SAS procedure includes the option NOTSORTED. Then, the BY statement in SAS is ignored, and the view descriptor ordering-clause is used.

Note:   When you include a SYSTEM 2000 ordering-clause in a view descriptor, you can specify a terminator, either a colon (:) or a semicolon (;). If you specify both a where-clause and an ordering-clause, do not use a terminator between them.  [cautionend]


ordering-clause Syntax (SYSTEM 2000)

ORDERED BY sortkeys;
ORDERED BY

is the keyword designating an ordering-clause. ORDER BY, OB, and SORT are aliases.

sortkeys

specifies the component name, component number, or the SAS variable name of a SYSTEM 2000 item that is included in the view descriptor. Use commas to separate sort keys, which might be specified in either ascending or descending order. The default is ascending order.

  • ASCENDING|ASCEND|ASC|LOW|LO specifies that you want the data ordered by ascending values of the sort key.

  • DESCENDING|DESCEND|DESC|HIGH|HI specifies that you want the data ordered by descending values of the sort key.

If you specify more than one SYSTEM 2000 component, the values are ordered by the component that is named first, followed by the second component, and so on. For more information about the ordering-clause, see QUEST Language and System-Wide Commands, Version 12.


ordering-clause Example (SYSTEM 2000)

The following ordering-clause specifies that the values be sorted in ascending order based on the values in item DEPARTMENT and then, within departments, the values in item SALARY are sorted in descending order.

    order by department, desc salary

space
Previous Page | Next Page | Top of Page