The basic method for grouping data
is to use a BY statement:
The BY statement can
be used in a DATA step with a SET, MERGE, MODIFY, or UPDATE statement,
or it can be used in SAS procedures.
To work with grouped
data using the SET, MERGE, MODIFY, or UPDATE statements, the data
must meet these conditions:
The observations must be in a SAS
data set, not an external file.
The variables that define the groups
must appear in the BY statement.
All observations in the input data set must be in ascending or descending numeric or character order, or grouped in some way, such as by calendar month or by a formatted value, according to the variables ...