Statalist The Stata Listserver


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

st: RE: Dichotomizing a Variable


From   "Maarten Buis" <[email protected]>
To   <[email protected]>
Subject   st: RE: Dichotomizing a Variable
Date   Fri, 7 Apr 2006 17:00:17 +0200

sort abc
gen abcnew = _n > _N/2

HTH,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology 
Vrije Universiteit Amsterdam 
Boelelaan 1081 
1081 HV Amsterdam 
The Netherlands

visiting adress:
Buitenveldertselaan 3 (Metropolitan), room Z214 

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Reg Jordan
Sent: vrijdag 7 april 2006 16:31
To: [email protected]
Subject: st: Dichotomizing a Variable

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?

Thanks for the assistance.

reg

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

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