As featured in: Data Management Solutions Using SAS Hash Table Operations: A Business Intelligence Case Study , and built from this github repository.
Chapter 4 Enumerating from Key-Item Snippet.sas
1 /* "Chapter 4 Enumerating from Key-Item Snippet.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  dcl hash H (multidata:"Y", ordered:"A") ;
8  H.definekey ("K") ;
9  H.definedata ("D", "K") ;
10  H.definedone () ;
11  do K = 1, 2, 2, 3, 3, 3 ;
12  q + 1 ;
13  D = char ("ABCDEF", q) ;
14  H.add() ;
15  end ;
16  DECLARE HITER IH ;
17  IH = _NEW_ hiter ("H") ;
18  call missing (K, D) ;
19  RC = IH.SETCUR(KEY:3) ;
20  do count = 1 to 2 while (RC = 0) ;
21  RC = IH.PREV() ;
22  if RC = 0 then put K= D= RC= ;
23  end ;
24  stop ;
25 run ;