Use the SORT procedure to reorder observations in a dataset.
PROC SORT DATA=one; BY treatment rep;
will put the observations in alpha-numerical order, with treatment A rep 1 first, A-2 second, etc.
PROC SORT is only necessary if you are running some procedure with a BY statement. Then the dataset must be sorted by the same variables. For example, this code
PROC SORT; BY treatment rep;
PROC PRINT; BY treatment rep;
needs the PROC SORT to reorder the dataset for use by PROC PRINT.
Occasionally you might need a dataset sorted in reverse order. These statements
PROC SORT DATA=one; BY DESCENDING treatment rep;
while sort treatment in reverse order, but rep will be sorted in the default ascending order. This puts treatment Z rep 1 first, and treatment A rep 10 last.
The DESCENDING option must be used in front of each variable which is to be sorted in reverse, for example
PROC SORT DATA=one; BY DESCENDING treatment DESCENDING rep;
Related Topics: Using SAS: Table of Contents