Use an "egen" function to generate a variable containing the Xth percentile of another variable. Make sure that this new variable is temporary. Use the new variables to calculate the difference between the percentiles.