![]() Chapter Contents |
![]() Previous |
![]() Next |
| BY |
| Valid: | in a DATA step or a PROC step |
| Category: | File-handling |
| Type: | Declarative |
Syntax |
|
BY <DESCENDING>
<GROUPFORMAT> variable-1
<. . .<DESCENDING> <GROUPFORMAT> variable-n> <NOTSORTED>; |
| Restriction: | You cannot use the DESCENDING option with indexed data sets because indexes are always stored in ascending order. |
| Featured in: | Specifying Sort Order |
| Featured in: | Grouping Observations By Using Formatted Values |
| Details |
Note:
MODIFY does not require sorted
data, but sorting can improve performance.
| Examples |
by dept;
by city zipcode;
by salesrep descending jansales;
by descending bedrooms descending price;
Observations are ordered by the name of the month in which the expenses were accrued:
by month notsorted;
Use PROC FORMAT to create the user-defined format RANGE:
proc format; value range 1-2='LOW' 3-4='MEDIUM' 5-6='HIGH'; run;Create a data set ordered by formatted values. TEST must already be ordered by the stored values of SCORE. BY GROUPFORMAT causes TEST to be processed in BY groups based on the formatted values of SCORE and creates NEWTEST in this order:
data newtest; set test; format score range.; by groupformat score; run;PROC PRINT uses the format RANGE to write the values of SCORE:
proc print data=newtest; var name score by score; format score range.; run;
| See Also |
Statements:
|
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.