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]
st: AW: AW: recoding a variable
From 
 
"Martin Weiss" <[email protected]> 
To 
 
<[email protected]> 
Subject 
 
st: AW: AW: recoding a variable 
Date 
 
Thu, 18 Feb 2010 14:05:44 +0100 
<> 
As always with the "greater than" operator in Stata, special care should be
taken with regard to missings. So my expanded advice for you would be to
explicitly account for them:
*************
clear*
set obs 10000
 
gen var=runiform()
su var
//introduce missings
replace var=. in 5/8
ins var
//explicity deal with missings
gen byte newvar=var>.5 & !mi(var)
ta newvar, mis
l in 1/10, noo
*************
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Martin Weiss
Gesendet: Donnerstag, 18. Februar 2010 13:53
An: [email protected]
Betreff: st: AW: recoding a variable
<> 
*************
replace var=var>.5
*************
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Data Analytics
Corp.
Gesendet: Donnerstag, 18. Februar 2010 01:12
An: [email protected]
Betreff: st: recoding a variable
Hi,
I got some very good quick advice on a looping question I asked 
earlier.  I have another question.  Suppose I have a variable with 
values that range between 0 ands 1.  I simply want to recode this so 
that any value greater than 0.5 becomes a 1, and 0 otherwise.  How do I 
do this?
Thanks,
Walt
-- 
________________________
Walter R. Paczkowski, Ph.D.
Data Analytics Corp.
44 Hamilton Lane
Plainsboro, NJ 08536
________________________
(V) 609-936-8999
(F) 609-936-3733
[email protected]
www.dataanalyticscorp.com
*
*   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/
*
*   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/