Solution

You can find the values of the quartiles by adding the details option to sum:

sum mpg, d

Now look at the r vector to see where the numbers you want are stored:

return list

You numbers you want are called r(p75) and r(p25). To calculate their difference, type:

gen iqr=r(p75)-r(p25)

You can see the value by typing:

tab iqr

Last Revised: 9/17/2010