[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: question on xtile using cutpoints

From   Maarten buis <>
To   stata list <>
Subject   Re: st: question on xtile using cutpoints
Date   Wed, 22 Oct 2008 18:19:59 +0100 (BST)

--- Sharon Kane <> wrote to me privately:

> Thanks Maarten, that does help some, but here is the rest of the
> specifics.  I have two choices for my cutpoints - 1. the original
> variable and 2. the variable containing quintiles 1-5.  When I select
> either of those as my cutpoints for the new variable, the results are
> strange.  Any further suggestions?

It is usually better to respond to the statalist for reasons discussed
in section 5 of the statalist FAQ.

A quick and dirty method is shown in the example below:

*------------- begin example -------------
// prepare the data
tempfile benchmark newdata

sysuse auto, clear
keep if foreign == 0
save `benchmark'

sysuse auto, clear
keep if foreign == 0
save `newdata'

// collect the cutvalues
use `benchmark', clear
_pctile mpg , nquantile(5)
return list

// apply these cutvalues to new data
use `newdata', clear
gen bench = .
forvalues i = 1/4 {
	replace bench = `r(r`i')' in `i'
list bench in 1/10
xtile newvar = mpg, cutpoints(bench)
tab newvar
tab mpg newvar
*------------- end example ----------------
(For more on how to use examples I sent to the Statalist, see )

Hope this helps,

Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room N515

+31 20 5986715

*   For searches and help try:

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