Terminology aside, my guess is that -xtile- is fairly old and in origin
predates numlists. I'd have to rummage in old manuals to be sure.
Nick
[email protected]
Maarten buis
I understand the confusion though, the syntax of -xtile- does not look
very Stataish to me (to borrow some Coxish terminology). I would have
expected that the cutpoints should be given to -xtile- as a numlist
instead of storing these as a variable. Maybe the numlist causes
problems if you want to specify a lot of cutpoints, but I don't know.
> --- Sharon Kane <[email protected]> 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
> http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )
>
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/