As featured in: Data Management Solutions Using SAS Hash Table Operations: A Business Intelligence Case Study , and built from this github repository.
Chapter 10 Selective Unduplication via Hash.sas
1 /* "Chapter 10 Selective Unduplication via Hash.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 (ordered:"A") ;
8  h.defineKey ("Home_SK") ;
9  h.defineData ("Home_SK", "Date", "Away_SK") ;
10  h.defineDone () ;
11  do until (lr) ;
12  set dw.Games (keep=Date Home_SK Away_SK Month DayOfWeek) end=lr ;
13  where Home_SK in (203,246,281) and Month=5 and DayOfWeek=7 ;
14  _Date = Date ;
15  _Away_SK = Away_SK ;
16  if h.find() ne 0 then h.add() ;
17  else if _Date > Date then
18  h.replace(key:Home_SK, data:Home_SK, data:_Date, data:_Away_SK) ;
19  end ;
20  h.output (dataset: "Last_games_hash") ;
21  stop ;
22 run ;