Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: Dichotomizing a Variable


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: Dichotomizing a Variable
Date   Fri, 7 Apr 2006 17:54:33 +0100

This will give you the wrong answer 
if there are any missings, and is
tricky to extend to problems with -if-
or -in-. Then there is the issue of -by-. 

An alternative is to link this 
to existing functions. 

FAQ     . . . . . . . . . . Calculating percentile ranks or plotting positions
        7/02    How can I calculate percentile ranks?
                How can I calculate plotting positions?
                http://www.stata.com/support/faqs/stat/pcrank.html

will lead you to a more general strategy. 

Nick 
n.j.cox@durham.ac.uk 

Maarten Buis
 
> sort abc
> gen abcnew = _n > _N/2

Reg Jordan
 
> Suppose I have a variable, abc that consists of: 1 2 3 4 5 5 
> 6 7 8 9. I want
> to dichotomize the variable at the median.
> 
> generate abcnew = 0
> replace abcnew = 1 if abc > 5
> 
> What statement do I write that assigns one of the 5s a 0 and 
> the other 5 a 1
> in abcnew?

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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