HOME Module List Site Index About This Site glossary" Resources Innovative Technology Center UT Statistics Courses
Using SAS Choose Design ANOVA Compare Means Regression Examples
Using SAS Using SAS: Table of Contents

Basic procedures
PROC Sort

Use the SORT procedure to reorder observations in a dataset.
PROC SORT DATA=one; BY treatment rep;
RUN;
will put the observations in alpha-numerical order, with treatment A rep 1 first, A-2 second, etc.
    example

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;
RUN;

needs the PROC SORT to reorder the dataset for use by PROC PRINT.
    example

Occasionally you might need a dataset sorted in reverse order. These statements
PROC SORT DATA=one; BY DESCENDING treatment rep;
RUN;

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;
RUN;

    example

 

 

 

Related Topics:                                                                                                     Using SAS: Table of Contents
PROC Print
PROC Sort
PROC Means
PROC Univariate

Home | Contact us | Module list & summary | Glossary/Terms | About this site | Stats courses | Links | Index