SAS Proc Sort Screenshots Tutorial
Proc sort arranges observations of the data set.
- Can create a new SAS data set containing rearranged observations.
- Sorts ascending (default) and descending.
- Does not provide printed output (that requires the proc print statements).
- Treats missing data as smallest possible value.

In the above example, we have sorted the departments in alphabetical order and used proc print to print the department, satisfaction score, and year data only.
proc print data=train.sastraining;
by department;
proc print data=train.sastraining NOOBS;
var department satisfaction years;
run;

In the above example, we have sorted by department and then printed by department including a column total for years.
proc sort data=train.sastraining;
by department;
proc print data=train.sastraining NOOBS;
by department
sum years;
run;

Finally, in this example above, we have sorted by department and then used Pageby in proc print to put each department's data on a different page.
proc sort data=train.sastraining;
by department;
proc print data=train.sastraining NOOBS;
by department;
pageby department;
sum years;
run;
For additional questions or assistance, contact Tina Ughrin.