Bookmark and Share



st: making quantiles based on controls

From   "Delahanty, Ryan" <>
To   "" <>
Subject   st: making quantiles based on controls
Date   Thu, 14 Oct 2010 10:46:02 -0500

I spend way too much time turning things into tertiles, quartiles, etc. 

So say I have to split a continuous variable like bmi into quartiles based on CONTROL values, I have to do this:

(In this example affection status of 1 = case, 0 = control).

by affection, sort: summarize bmi, detail
(which tells me the splits, and then I use them like so)
generate bmiquart = 0
replace bmiquart=1        if             21<bmi<=23
replace bmiquart=2        if             23<bmi<=26
replace bmiquart=3        if             26<bmi

and then I generate the dummies for bmiquart as I do the regression with something like this:
xi, prefix(): logistic affecttion age income education i.bmiquart

But the above is kind of cumbersome when splitting data a billion different ways. I'd like to substitute the first five lines and instead use a command like this: 
xtile bmiquart = bmi, nquantiles(4)

The problem with this is that this will just split it based on bmi for cases and controls. Is there a simple command or switch that will allow the quantiles to be generated based on the distribution in controls rather than both?


*   For searches and help try:
