Kontopantelis, Evangelos. “A Greedy Algorithm for Representative Sampling: Repsample in Stata”.
Journal of Statistical Software, Code Snippets
, vol. 55, no. 1, Nov. 2013, pp. 1-19, doi:10.18637/jss.v055.c01.