Chapter Contents

Previous

Next
SAS/ACCESS Interface to CA-DATACOM/DB: Reference

SORT Clause in a View Descriptor

When you define a view descriptor, you can also include a SORT clause to specify data order. You can reference only the CA-DATACOM/DB fields selected for the view descriptor.

Without a SORT clause or a SAS BY statement, the data order is determined by the Native Key for the CA-DATACOM/DB table (or by the Default Key specified in the access or view descriptor).

A SAS BY statement automatically issues a SORT clause to CA-DATACOM/DB. However, the SAS BY statement may cause grouping of the output results in some procedures; this may not be what you want.

If a view descriptor already contains a SORT clause, the BY statement overrides the SORT clause for that program. An exception is when the SAS procedure includes the NOTSORTED option. Then, the SAS BY statement is ignored, and the view descriptor SORT clause is used.


View SORT Clause Syntax

The syntax for the SORT clause is

SORT field-name <ASCENDING|UP|A> <DESCENDING|DOWN|D> 
   <,field-name...>
                     

The elements of the SORT clause are described here.

field-name
is a CA-DATACOM/DB field name or SAS column name of a CA-DATACOM/DB field included in the view descriptor. Use commas to separate sort keys. You can also specify either ascending or descending order for each field name.

ASCENDING|UP|A
specifies that you want the data ordered by ascending values of the field-name. ASCENDING is the default.

DESCENDING|DOWN|D
specifies that you want the data ordered by descending values of the field-name.

If you specify more than one CA-DATACOM/DB field, the values are ordered by the first named field, then the second, and so on.


SORT Clause Example

The following SORT clause causes the values to be presented in ascending order based on the values in field STATE, then within states in descending order based on the values in field CITY:

sort state, city down


Guidelines

Consider the following guidelines when you specify a SORT clause in the view descriptor:


Chapter Contents

Previous

Next

Top of Page

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