Statalist


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

st: R: replace command


From   "Carlo Lazzaro" <carlo.lazzaro@tin.it>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: R: replace command
Date   Mon, 8 Oct 2007 15:21:35 +0200

Ziad wrote:

Hi again
i created new variable for weight, called weightcat and wants to replace is
as replace weightcat = 1 if weight <= 90 or weight >= 80

STATA gives 'invalid or', any kind tips about how to make such condition?


Thank you in advance and best regards
ziad
*
*   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/

Dear Ziad, 

provided that I have understood your thread correctly, I tried successfully
what follows (please, see the example below):

-----------------------begin example----------------------------------------
clear
set obs 100
gen  weightcat=70 in 1/20
replace  weightcat=80 in 21/40
replace  weightcat=85 in 41/50
replace  weightcat=65 in 51/100
count if  weightcat<= 90
count if  weightcat >= 80
replace weightcat = 1 if weightcat <= 90 | weightcat >= 80
-----------------------end example----------------------------------------

Hope this helps and Kind Regards,

Carlo


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