Sometimes you want to display the percentiles of a variable to get an idea of how values are distributed. One way of achieving this is by using the pctile command which creates a variable containing the percentiles according to specification. In order to get every 10th percentile (ie. from 10 to 90), we utilize the nquantiles option (number of quantiles) option, like so:
sysuse nlsw88, clear
pctile wage_percentiles = wage, nq(10)
list wage_percentiles in 1/10
In order to display the quartiles we can use xtile, which creates a variable containing quantile categories. Here’s an example:
xtile quarters = wage, nq(4)
list wage quarters, sep(4)
Here we are displayed with a listing detailing the value of the observation (ie. the wage) as well as the corresponding quartile.