As featured in: Data Management Solutions Using SAS Hash Table Operations: A Business Intelligence Case Study , and built from this github repository.
Chapter 9 Simple HoH.sas
1 /* "Chapter 9 Simple HoH.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  length Table $41;
8  dcl hash HoH();
9  HoH.defineKey ("Table");
10  HoH.defineData("H","Table");
11  HoH.defineDone();
12  dcl hash h();
13 
14  Table = "DW.AtBats";
15  h = _new_ hash(dataset:Table);
16  h.defineKey("Game_SK","Inning","Top_Bot","AB_Number");
17  h.defineData("Result");
18  h.defineDone();
19  HoH.add();
20 
21  Table = "DW.Pitches";
22  h = _new_ hash(dataset:Table);
23  h.defineKey("Game_SK","Inning","Top_Bot","AB_Number","Pitch_Number");
24  h.defineData("Result");
25  h.defineDone();
26  HoH.add();
27 
28  dcl hiter i_HoH("HoH");
29  do while (i_HoH.next() = 0);
30  Rows = h.num_items;
31  put (Table Rows)(=);
32  end;
33  stop;
34  set dw.pitches(keep = Game_SK Inning Top_Bot AB_Number Pitch_Number Result);
35 run;