Displaying percentiles in Stata 2

June 04, 2019

In a recent post we looked at listing percentiles of a variable. When it comes to getting an overview of a variable perhaps the simplest and most powerful command is summarize along with the detail option:

sysuse nlsw88, clear
summarize wage, detail

Summary of percentiles

This is great because we get a bunch of different percentiles, including quartiles without having to specify anything. In order to just get an overview this should suffice nicely. If there’s a need to look at more specific percentile (let’s say the 85th), we can do something like this:

xtile pct_85 = wage, nq(100)
summarize wage if pct_85==85

Percentile details

As we can see there are 23 observations that fall within the bracket of the 85th percentile.


Profile picture

Written by Johan Osterberg who lives and works in Gothenburg, Sweden as a developer specialized in e-commerce. Connect with me on Linkedin

2024 © Johan Osterberg