BY-Group Processing in the DATA Step |
Use one of the following forms for BY-group processing:
BY variable(s); |
BY <DESCENDING> variable(s) <NOTSORTED> <GROUPFORMAT>; |
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.
uses the formatted values, instead of the internal values, of the BY variables to determine where BY-groups begin and end, and therefore how FIRST.variable and LAST.variable are assigned. Although the GROUPFORMAT option can appear anywhere in the BY statement, the option applies to all variables in the BY statement.
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.
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.
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.