As featured in: Data Management Solutions Using SAS Hash Table Operations: A Business Intelligence Case Study , and built from this github repository.
Chapter 6 Reordering Split Outputs.sas
1 /* "Chapter 6 Reordering Split Outputs.sas" from the SAS Press book
2  Data Management Solutions Using SAS Hash Table Operations:
3  A Business Intelligence Case Study
4 */
5 
6 data _null_ ;
7  if _n_ = 1 then do ;
8  dcl hash h (multidata:"Y", ordered:"A") ;
9  * h.defineKey ("_n_") ;
10  h.defineKey ("Team_SK") ;
11  h.defineData ("League", "Team_SK", "Team_Name") ;
12  h.defineDone () ;
13  end ;
14  do until (last.League) ;
15  set bizarro.Teams ;
16  by League ;
17  h.add() ;
18  end ;
19  h.output (dataset: catx ("_", "work.League", League)) ;
20  h.clear() ;
21 run ;