Refer to this SUGI paper
Several options are indicated to reduce the probability of getting an error when proc sorting a large dataset in the mainframe environment. I have pasted one option below.
This code limits the number of sort work areas in the SAS code...use SOTWKNO option either as a global option or as a PROC SORT option. This option determines the maximum number of sort work areas that PROC SORT is allowed to use.
options SORTWKNO=3;
proc sort test_history SORTWKNO=5;
by acct score;
run;