As featured in: Data Management Solutions Using SAS Hash Table Operations: A Business Intelligence Case Study , and built from this github repository.
Chapter 3 Insertion Order Demo.sas
1 /* "Chapter 3 Insertion Order Demo.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  do dupes = "Y", "N" ;
8  do order = "N", "A", "D" ;
9  dcl hash H (multidata: dupes, ordered: order) ;
10  H.definekey ("K") ;
11  H.definedata ("K", "D") ;
12  H.definedone () ;
13  do K = 2, 3, 1 ;
14  do D = "A", "B", "C" ;
15  rc = h.add() ;
16  end ;
17  end ;
18  h.output (dataset:catx ("_", "Hash", dupes, order)) ;
19  end ;
20  end ;
21 run ;