Statalist


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

st: RE: what does Stata do when I type "var1==var2==0"?


From   "Kieran McCaul" <[email protected]>
To   <[email protected]>
Subject   st: RE: what does Stata do when I type "var1==var2==0"?
Date   Fri, 26 Sep 2008 11:38:11 +0800

If your data looked like this:
var1 var2
3    3
1    1

then -assert var1==var2==1- would return no contradictions,
-assert (var1==var2)==1- would return no contradictions, but
-assert var1==(var2==1)- would return one contradiction.

So it appears that Stata is interpreting -var1==var2==1- as
-(var1==var2)==1- which is what I would expect.

I wouldn't use this though.  If I wanted to know if both
both var1 and var2 were coded 1, I would use:
-(var1==1) & (var2==1)-
This is explicitly what you want.

______________________________________________
Kieran McCaul MPH PhD
WA Centre for Health & Ageing (M573)
University of Western Australia
Level 6, Ainslie House
48 Murray St
Perth 6000
Phone: (08) 9224-2140
Fax: (08) 9224 8009
email: [email protected]
http://myprofile.cos.com/mccaul 
_______________________________________________
The fact that no one understands you doesn't make you an artist.

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Hau Chyi
Sent: Friday, 26 September 2008 9:18 AM
To: [email protected]
Subject: st: what does Stata do when I type "var1==var2==0"?

Dear listers,

I have 4 observations for two variables that look like this:
var1 var2
0    0
0    1
1    0
1    0

when I type:
-assert var1==var2==1-
Stata returns:
-3 contradictions in 4 observations-

I realize I need to type:
-assert var1==1 & var2==1- to get the right answer.

I have a vague idea as to why Stata prefers the second one. But what's
intrinsically wrong with the first one?

Thanks in advance!

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



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