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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: Converting a continuous var into a binary var |

Date |
Mon, 6 Jul 2009 19:50:42 +0100 |

Your boss just emailed me that he's not impressed by this post, as he realises that you won't deserve any credit for a solution. Nevertheless consider this: su x, detail gen y = x > r(p10) if x < . Nick n.j.cox@durham.ac.uk Pancho Villa 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. * * 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/

**Follow-Ups**:**Re: st: RE: Converting a continuous var into a binary var***From:*Pancho Villa <panchovillainnyc@gmail.com>

**References**:**st: Converting a continuous var into a binary var***From:*Pancho Villa <panchovillainnyc@gmail.com>

- Prev by Date:
**st: Converting a continuous var into a binary var** - Next by Date:
**st: difference between cdsimeq, ivprobit and ivreg2** - Previous by thread:
**st: Converting a continuous var into a binary var** - Next by thread:
**Re: st: RE: Converting a continuous var into a binary var** - Index(es):

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