As featured in: Data Management Solutions Using SAS Hash Table Operations: A Business Intelligence Case Study , and built from this github repository.
Chapter 8 Slash Line with Name.sas
1 /* "Chapter 8 Slash Line with Name.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 slashline(ordered:"A");
8  slashline.defineKey("Last_Name","First_Name","Batter_ID");
9  slashline.defineData("Batter_ID","Last_Name","First_Name","Team_SK"
10  ,"PAs","AtBats","Hits","_Bases","_Reached_Base"
11  ,"BA","OBP","SLG","OPS");
12  slashline.defineDone();
13  if 0 then set dw.players(rename=(Player_ID=Batter_ID));
14  dcl hash players(dataset:"dw.players(rename=(Player_ID=Batter_ID))"
15  ,duplicate:"replace");
16  players.defineKey("Batter_ID");
17  players.defineData("Batter_ID","Team_SK","Last_Name","First_Name");
18  players.defineDone();
19  format BA OBP SLG OPS 5.3;
20  do until(lr);
21  set dw.AtBats end = lr;
22  call missing(Last_Name,First_Name,Team_SK
23  ,PAs,AtBats,Hits,_Bases,_Reached_Base);
24  players.find();
25  rc = slashline.find();
26  PAs + 1;
27  AtBats + Is_An_AB;
28  Hits + Is_A_Hit;
29  _Bases + Bases;
30  _Reached_Base + Is_An_OnBase;
31  BA = divide(Hits,AtBats);
32  OBP = divide(_Reached_Base,PAs);
33  SLG = divide(_Bases,AtBats);
34  OPS = sum(OBP,SLG);
35  slashline.replace();
36  end;
37  slashline.output(dataset:"Batter_Slash_Line(drop=_:)");
38 run;