Group Processing Using the BY Statement

Like the CLASS statement, the BY statement specifies variables to use for categorizing observations.
General form, BY statement:
BY variable(s);
where variable(s) specifies category variables for group processing.
But BY and CLASS differ in two key ways:
  1. Unlike CLASS processing, BY processing requires that your data already be sorted or indexed in the order of the BY variables. Unless data set observations are already sorted, you will need to run the SORT procedure before using PROC MEANS with any BY group.
    CAUTION:
    Be careful when sorting data sets to enable group processing. If you don't specify an output data set by using the OUT= option, PROC SORT will overwrite your initial data ...

Get SAS Certification Prep Guide: Base Programming for SAS 9, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.