Statalist


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

st: Converting a continuous var into a binary var


From   Pancho Villa <panchovillainnyc@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Converting a continuous var into a binary var
Date   Mon, 6 Jul 2009 14:45:26 -0400

Hi,

It couldn't get more basic than this.  I'm creating a binary variable
y.  The criteria for y to be equal to one is that the value of x is
greater than its 10th percentile value.  Otherwise it'll be zero.

So I tried to this, but it didn't work:

********************************
gen y=0
replace y=1 if x>p10(x)
********************************

Now, I know I can collapse x and get p10 that way, and then use the
p10 value to create y.  But I want something just a tiny bit more
elegant to impress my boss.

Please help.

Thanks in advance,

PV
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index