Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: making quantiles based on controls


From   Tim Wade <[email protected]>
To   [email protected]
Subject   Re: st: making quantiles based on controls
Date   Fri, 15 Oct 2010 22:40:18 -0400

I think this will work (substitute case/control for foreign)

sysuse auto.dta
*generate cutpoints based on foreign=0
pctile ptile=mpg if foreign==0, nq(4)

*create categorical variable for all observations based on cutpoints
of foreign=0
xtile mpgcat=mpg, cutpoints(ptile)

hope this helps, Tim


On Thu, Oct 14, 2010 at 11:46 AM, Delahanty, Ryan
<[email protected]> wrote:
> 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?
>
> Thanks,
> Ryan
>
> *
> *   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/
>

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index