Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: RE: if programming command


From   Nick Winter <nwinter@virginia.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: if programming command
Date   Thu, 09 Oct 2008 13:21:46 -0400

Aside from the point that -if- as a programming command does not evaluate observation-by-observation, I wonder about part of your -if- condition.

Does not

(lbresc!="POSITIVE 1:128" | lbresc!="POSITIVE 1:16")

always evaluate to TRUE? That is, whatever the value of lbresc, that value will be different from (at least) one of those two things. Perhaps you intend "&" rather than "|" between those two?

--Nick Winter

Martin Weiss wrote:
What is different about the results? Give us more info! We have had a lot of
posts about the difference between the -if- qualifier and the -if-
programming command in the past...


HTH
Martin


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of lou apicella
Sent: Thursday, October 09, 2008 5:55 PM
To: statalist@hsphsun2.harvard.edu
Subject: st: if programming command

Hello Statalisters,

I'm trying to convert some logical statements into nested if statements. I
feel the two statements below should give the same result but they do not.
What am I do wrong here?

Thanks in advance.

Lou.

replace syphilis=1 if visit==1 & lbcd=="SYP_RPR" & (lbresc!="POSITIVE 1:128"
| lbresc!="POSITIVE 1:16")



if visit==1 {
    if lbcd=="SYP_RPR" & (lbresc!="POSITIVE 1:128" | lbresc!="POSITIVE 1:16"
) {
                replace syphilis==1
     }
}


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

--
--------------------------------------------------------------
Nicholas Winter                                 434.924.6994 t
Assistant Professor                             434.924.3359 f
Department of Politics                  nwinter@virginia.edu e
University of Virginia          faculty.virginia.edu/nwinter w
PO Box 400787, 100 Cabell Hall
Charlottesville, VA 22904

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



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index