BYSORT= Table Option

Specifies to perform an implicit automatic sort when SPD Server encounters a BY clause for a given table.

Valid in: SPD Server
Default: YES
Interaction: Corresponding macro variable is SPDSBSRT.

Syntax

BYSORT=YES | NO

Required Arguments

YES

sorts the data based on the BY columns and returns the sorted data to the SAS client. This powerful capability means that the user does not have to sort data using a PROC SORT statement before using a BY clause.

NO

does not sort the data based on the BY columns. This might be desirable if a DATA step BY clause has a GROUPFORMAT option or if a PROC step reports grouped and formatted data.

Details

The default is YES. The NO argument means that the table must have been previously sorted by the requested BY columns. The NO argument allows data to retain its precise order in the table. A YES argument groups the data correctly but possibly in a different order from the order in the table.

Examples

Example 1: Group Formatting with the BYSORT= Table Option

The following example uses group formatting with BYSORT= table option.
libname sport sasspds 'mylib'
   host='samson'
   user='user19'
   passwd='dummy2';

PROC FORMAT;
   value dollars
     0-99.99="low"
     100-199.99="medium"
     200-1000="high";
run;

data sport.racquets;
   input
     raqname $20.
     @22 weight
     @28 balance $2.
     @32 flex
     @36 gripsize
     @42 string $3.
     @47 price
     @55 instock;

   datalines;
Solo Junior          10.1   N   2  3.75  syn   50.00   6
Solo Lobber          11.3   N  10  5.5   syn  160.00   1
Solo Queensize       10.9  HH   6  5.0   syn  130.00   3
Solo Kingsize        13.1  HH   5  5.6   syn  140.00   3
;

PROC PRINT data=sport.racquets (bysort=yes);
   var raqname instock;
   by price;
   format price dollars.;
title 'Solo Brand Racquets by Price Level';
run;

Report Output with BYSORT=
                Solo Brand Racquets by Price Level

---------------------------- Price=low ---------------------------

OBS                           RAQNAME                      INSTOCK

 1                          Solo Junior                       6

-------------------------- Price=medium --------------------------

OBS                           RAQNAME                      INSTOCK

 3                         Solo Queensize                     3

 4                         Solo Kingsize                      3

 2                          Solo Lobber                       1

Example 2: Group Formatting without the BYSORT= Table Option

The following example uses group formatting without the BYSORT= table option.
PROC PRINT data=sport.racquets (bysort=no);
   var raqname instock;
   by price;
   format price dollars.;
title 'Solo Brand Racquets by Price Level';
run;  
Report Output without BYSORT=
                Solo Brand Racquets by Price Level

---------------------------- Price=low ---------------------------

OBS                           RAQNAME                      INSTOCK

 1                          Solo Junior                       6

-------------------------- Price=medium --------------------------

OBS                           RAQNAME                      INSTOCK

 2                          Solo Lobber                       1

 3                         Solo Queensize                     3

 4                         Solo Kingsize                      3

See Also

Macro variables:
Last updated: February 8, 2017