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 Aggregation Inning.sas
1 /* "Chapter 11 Frontal Attack Aggregation Inning.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 Scores_game_inning (keep = Game_SK Inning Top_Bot Score) ;
7  if _n_ = 1 then do ;
8  dcl hash h (ordered:"A") ;
9  h.defineKey ("Game_SK", "Inning", "Top_Bot") ;
10  h.defineData ("Game_SK", "Inning", "Top_Bot", "Score") ;
11  h.defineDone () ;
12  dcl hiter ih ("h") ;
13  end ;
14  do until (LR) ;
15  set Dw.Runs (keep = Game_SK Inning Top_Bot) end = LR ;
16  if h.find() ne 0 then Score = 1 ;
17  else Score + 1 ;
18  h.replace() ;
19  end ;
20  do while (ih.next() = 0) ;
21  output ;
22  end ;
23 run ;