Chapter Contents

Previous

Next

Syntax

Use one of the following forms for BY-group processing:

BY variable(s);
BY <GROUPFORMAT> <DESCENDING> variable(s) <NOTSORTED>;

where

variable
names each variable by which the data set is sorted or indexed.

Note:   All data sets must be ordered or indexed on the values of the BY variable if you process them using the SET, MERGE, or UPDATE statements. If you use the MODIFY statement, your data does not need to be ordered. However, your program might run more efficiently with ordered data. All data sets that are being combined must include the BY variable or variables. The position of the BY variable in the observations does not matter.   [cautionend]

GROUPFORMAT
uses the formatted values, instead of the stored values, of the variable when you reference FIRST.variable and LAST.variable in a DATA step. If you have more that one variable in the BY group, GROUPFORMAT applies only to the variable that immediately follows it.

DESCENDING
indicates that the data sets are sorted in descending order (largest to smallest) by the variable that is specified. If you have more that one variable in the BY group, DESCENDING applies only to the variable that immediately follows it.

NOTSORTED
specifies that observations with the same BY value are grouped together but are not necessarily stored in alphabetical or numeric order.

For complete information about the BY statement, see SAS Language Reference: Dictionary.


Chapter Contents

Previous

Next

Top of Page

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