PriceStats interview question

STATA coding, with calculation and some data management.