Productivity is often computed by approximating the weighted sum of the inputs from the estimation of the Cobb–Douglas production function. Such estimates, however, may suffer from simultaneity and selection biases. Olley and Pakes (1996, Econometrica 64: 1263–1297) introduced a semiparametric method that allows us to estimate the production function parameters consistently and thus obtain reliable productivity measures by controlling for such biases. This study first reviews this method and then introduces a Stata command to implement it. We show that when simultaneity and selection biases are not controlled for, the coefficients for the variable inputs are biased upward and the coefficients for the fixed inputs are biased downward.