How to group income values into percentiles, deciles and quartiles
This example demonstrates how to convert from income values measured as amounts into divisions like percentiles, deciles and quartiles. It also shows how to controle the outcome of the conversion.
//Create a dataset containing an income variable create-dataset percentiletest import INNTEKT_WLONN 2015-01-01 as salary15 //Produce income statistics measured in 2015 (all individuals with positive income this year) summarize salary15 histogram salary15 //Convert into percentiles and test the division generate percentile15 = quantile(salary15,100) histogram percentile15, discrete textblock NB! Note that the 1st percentil is fusioned with the 2nd due to the 1% bottom coding. This will sometimes happen if the 1st percentile is slightly below the 1% limit (0.99). In principle, this will also be the case for the last percentile (100th) due to the 1% top coding. endblock //Convert into quartiles and test the division generate quartile15 = quantile(salary15,4) histogram quartile15, discrete //Test the percentile and quartile divisions up against each other tabulate percentile15 quartile15 //Convert into deciles and show the frequencies, means and limit values within each decile generate decile15 = quantile(salary15,10) tabulate decile15, missing tabulate decile15, summarize( salary15 ) tabulate decile15, summarize( salary15 ) min