As featured in: Data Management Solutions Using SAS Hash Table Operations: A Business Intelligence Case Study , and built from this github repository.
Chapter 8 Mode.sas
1 /* "Chapter 8 Mode.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 Modes;
7  keep Distance Count;
8  format Distance Count comma5.;
9  dcl hash mode();
10  mode.defineKey("Distance");
11  mode.defineData("Distance","Count");
12  mode.defineDone();
13  dcl hiter iterM("mode");
14  do until(lr);
15  set dw.AtBats(keep=Distance) end=lr;
16  where Distance gt .;
17  if mode.find() ne 0 then Count = 0;
18  Count + 1;
19  mode.replace();
20  maxCount = max(Count,maxCount);
21  end;
22  do i = 1 to mode.num_items;
23  iterM.next();
24  if Count = maxCount then output;
25  end;
26  stop;
27 run;