As featured in: Data Management Solutions Using SAS Hash Table Operations: A Business Intelligence Case Study , and built from this github repository.
Chapter 11 Hash Index Selective Unduplication.sas
1 /* "Chapter 11 Hash Index Selective Unduplication.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 Last_away_hash_RID (drop = _:) ;
7  dcl hash h (ordered:"A") ;
8  h.defineKey ("Home_SK") ;
9  h.defineData ("Date", "RID") ;
10  h.defineDone () ;
11  do _RID = 1 by 1 until (lr) ;
12  set dw.Games (keep = Date Home_SK) end = lr ;
13  _Date = Date ;
14  RID = _RID ;
15  if h.find() ne 0 then h.add() ;
16  else if _Date > Date then
17  h.replace (key:Home_SK, data:_Date, data:_RID) ;
18  end ;
19  dcl hiter hi ("h") ;
20  do while (hi.next() = 0) ;
21  set dw.Games (keep = Home_SK Away_SK Game_SK) point = RID ;
22  output ;
23  end ;
24  stop ;
25 run ;