As featured in: Data Management Solutions Using SAS Hash Table Operations: A Business Intelligence Case Study , and built from this github repository.
Chapter 11 Frontal Attack Selective Unduplication.sas
1 /* "Chapter 11 Frontal Attack 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 _null_ ;
7  dcl hash h (ordered:"A") ; *Output in Home_SK order;
8  h.defineKey ("Home_SK") ;
9  h.defineData ("Home_SK", "Away_SK", "Date", "Game_SK") ;
10  h.defineDone () ;
11  do until (lr) ;
12  set dw.games (keep = Game_SK Date Home_SK Away_SK) end = lr ;
13  _Away_SK = Away_SK ;
14  _Date = Date ;
15  _Game_SK = Game_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:_Away_SK, data:_Date
19  , data:_Game_SK
20  ) ;
21  end ;
22  h.output (dataset: "Last_games_hash") ;
23  stop ;
24 run ;