Statalist The Stata Listserver


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

Re: st: use of *OR* | in 'replace'


From   Henrik Stovring <hstovring@health.sdu.dk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: use of *OR* | in 'replace'
Date   Thu, 02 Mar 2006 12:23:12 +0100

You seem to have left out the actual OR statement:

. replace Include=1 if Temp==41.5 Dose_Group > 2

should read

. replace Include=1 if Temp==41.5 | Dose_Group > 2

Best,

Henrik

Steffen Hokland wrote:
>> . replace Include=1 if Temp==1 | Dose_Group<35
>> (26 real changes made)
> Well it's obviously possible. However, what about this one:
> 
> ***************************************************************
>  set obs 10
> obs was 0, now 10
> 
> . gen mouse = _n
> 
> . gen Dose_Group = 1
> 
> . replace Dose_Group = 2 if mouse > 32
> (0 real changes made)
> 
> . replace Dose_Group = 2 if mouse > 3
> (7 real changes made)
> 
> . replace Dose_Group = 3 if mouse > 6
> (4 real changes made)
> 
> . gen Temp=41.5
> 
> . replace Temp = 42.5 if mouse > 5
> (5 real changes made)
> 
> . gen Include = 0
> 
> . replace Include=1 if Dose_Group > 2 | Temp==41.5
> (9 real changes made)
> 
> . drop Include
> 
> . gen Include = 0
> 
> . replace Include=1 if Temp==41.5 Dose_Group > 2
> invalid 'Dose_Group'
> r(198);
> ***************************************************************
> 
> I'm certain that there's some logical explanation - it just eludes me.
> 
> Steffen
> *
> *   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/
> 

-- 
Henrik StÝvring, PhD

Research Unit of General Practice
University of Southern Denmark
J.B. WinslÝws Vej 9
DK-5000 Odense C
Phone: (+45) 6550 3692
Fax: (+45) 6591 8296
email: hstovring@health.sdu.dk
Homepage: http://www.biostat.sdu.dk/~stovring
------------------------------------------------------------------
*
*   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–2020 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index