Thursday, March 31, 2011

SORT and BY

When you use BY-group processing (without options) in the DATA step, the data set has to be either sorted by the BY variables or indexed by the BY variables.
BY statement is usually coupled with SET, MERGE, UPDATE or MODIFY.
However, this rule has exception when you use NOTSORTED or DESCENDING (?) option with SET statement (these options can't be used with MERGE, UPDATE or MODIFY).
Note: if you use NOTSORTED or DESCENDING option, the index will not be used with BY statement.
You can still use FIRST. and LAST. even when you use NOTSORTED option.

No comments: