As featured in: Data Management Solutions Using SAS Hash Table Operations: A Business Intelligence Case Study , and built from this github repository.
Chapter 10 Stable Unduplication via Hash.sas
1 /* "Chapter 10 Stable 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 nodup_hash dupes_hash ;
7  if _n_ = 1 then do ;
8  dcl hash h () ;
9  h.defineKey ("Batter_ID") ;
10  h.defineDone () ;
11  end ;
12  set dw.AtBats (keep = Game_SK Batter_ID Result Top_Bot Inning) ;
13  where Batter_ID in (32390,51986,60088)
14  and Result = "Triple"
15  and Top_Bot = "B"
16  and Inning = 1
17  ;
18  if h.check() ne 0 then do ;
19  output nodup_hash ;
20  h.add() ;
21  end ;
22  else output dupes_hash ;
23  keep Game_SK Batter_ID ;
24 run ;