Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: working with percentile cutpoints

From   "Brent Fulton" <>
To   <>
Subject   st: RE: working with percentile cutpoints
Date   Tue, 22 May 2007 08:26:37 -0700


I am not sure how to do it in one step, but you could do the following:

xtile temp =  var1, nq(100)   /* creates new variable of integers with range
of 1 to 100 indicating percentiles */
gen new_var1=.
replace new_var1=1 if inrange(temp,1,12)
replace new_var1=2 if inrange(temp,13,34)
replace new_var1=3 if inrange(temp,35,72)
replace new_var1=4 if inrange(temp,73,100)


Brent D. Fulton, PhD
Health Services Researcher
Petris Center, School of Public Health, UC Berkeley
Phone: 510-643-4102 
Fax: 510-643-4281

-----Original Message-----
[] On Behalf Of Visintainer, Paul
Sent: Tuesday, May 22, 2007 7:56 AM
Subject: st: working with percentile cutpoints

Is there a way to create a new variable that uses cutpoints based on unique
percentiles of distribution?  For example, suppose I want a new variable
with 4 groups at (or as close as the distribution will allow) the following
percentile cutpoints:  13th percentile, 35th percentile, and the 73rd
percentile?  I've looked at -xtile-, -pctile-, and -egen- and they don't
seem to allow for this option.

What am I missing?

Thanks for any help

Paul Visintainer


*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index