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.sas
1 /* "Chapter 8 Slash Line.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("Batter_ID");
9  slashline.defineData("Batter_ID","PAs","AtBats","Hits","_Bases","_Reached_Base"
10  ,"BA","OBP","SLG","OPS");
11  slashline.defineDone();
12  format BA OBP SLG OPS 5.3;
13  do until(lr);
14  set dw.AtBats end = lr;
15  call missing(PAs,AtBats,Hits,_Bases,_Reached_Base);
16  rc = slashline.find();
17  PAs + 1;
18  AtBats + Is_An_AB;
19  Hits + Is_A_Hit;
20  _Bases + Bases;
21  _Reached_Base + Is_An_OnBase;
22  BA = divide(Hits,AtBats);
23  OBP = divide(_Reached_Base,PAs);
24  SLG = divide(_Bases,AtBats);
25  OPS = sum(OBP,SLG);
26  slashline.replace();
27  end;
28  slashline.output(dataset:"Batter_Slash_Line(drop=_:)");
29 run;