Chapter Contents |
Previous |
Next |
Statements with the Same Function in Multiple Procedures |
See also: | Creating Titles That Contain BY-Group Information |
BY
<DESCENDING> variable-1
<... <DESCENDING> variable-n> <NOTSORTED>; |
Required Arguments |
Options |
The requirement for ordering or indexing observations according to the values of BY variables is suspended for BY-group processing when you use the NOTSORTED option. In fact, the procedure does not use an index if you specify NOTSORTED. The procedure defines a BY group as a set of contiguous observations that have the same values for all BY variables. If observations with the same values for the BY variables are not contiguous, the procedure treats each contiguous set as a separate BY group.
Note: You cannot use the NOTSORTED option in a PROC SORT step.
Note: You cannot use the GROUPFORMAT option,
which is available in the BY statement in a DATA step, in a BY statement in
any PROC step.
BY-Group Processing |
Note: All base procedures except PROC PRINT process BY groups
completely independently. PROC PRINT can report the number of observations
in each BY group as well as the number of observations in all BY groups. Similarly,
PROC PRINT can sum numeric variables in each BY group and across all BY groups.
You can use only one BY statement in each PROC step. When you use a BY statement, the procedure expects an input data set that is sorted by the order of the BY variables or one that has an appropriate index. If your input data set does not meet these criteria, an error occurs. Either sort it with the SORT procedure or create an appropriate index on the BY variables.
Depending on the order of your data, you may need to use the NOTSORTED or DESCENDING option in the BY statement in the PROC step.
For more information on
Procedures That Support the BY Statement |
CALENDAR | RANK | |
---|---|---|
CHART | REPORT (nonwindowing environment only) | |
COMPARE | SORT (required) | |
CORR | STANDARD | |
FORMS | SUMMARY | |
FREQ | TABULATE | |
MEANS | TIMEPLOT | |
PLOT | TRANSPOSE | |
UNIVARIATE |
Note: In the SORT procedure, the BY statement specifies how to sort
the data. With the other procedures, the BY statement specifies how the data
are currently sorted.
Example |
options nodate pageno=1 linesize=64 pagesize=40; proc print data=debate noobs; by year; title 'Printing of Team Members'; title2 'by Year'; run;
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.