As featured in: Data Management Solutions Using SAS Hash Table Operations: A Business Intelligence Case Study , and built from this github repository.
Chapter 8 Median.sas
1 /* "Chapter 8 Median.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 medianDist(dataset:"dw.AtBats(where=(Distance gt 0))"
8  ,multidata:"Y"
9  ,ordered:"A");
10  medianDist.defineKey("Distance");
11  medianDist.defineDone();
12  dcl hiter iterM("medianDist");
13  iterM.first();
14  do i = 1 to .5*medianDist.num_items - 1;
15  iterM.next();
16  end;
17  /* could add logic here to interpolate if needed */
18  put "The Median is " Distance;
19  stop;
20  set dw.AtBats(keep=Distance);
21 run;