Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: repost: -cond()- function


From   Michel Camus <[email protected]>
To   [email protected]
Subject   Re: repost: -cond()- function
Date   Thu, 01 Jan 2004 12:58:28 -0500

You are correct, Richard.
We agree, as per my 2nd posting.
Michel
====
Richard Williams wrote:

At 11:20 AM 1/1/2004 -0500, Michel Camus wrote:

I experience the same "problem" as you do, Paul.
I believe it has to do with "binary logic". The logical condition ("chol") always evaluates to 0 or 1, and nothing else, it never evaluates to "9" even if the original variable does have "9" as one value. The same happens even if your missing values in "chol" were already coded as "." See http://www.stata.com/support/faqs/data/values.html by W. Gould on "Logical expressions and missing values". The way to have missing values is tocondition your expression as follows :

However, the docs say this about the cond command:

"cond(x,a,b,c) returns a if x evaluates to true (not 0), b if x evaluates to false (0), and c if x evaluates to missing (.)."

So, it seems it should work (assuming his md value is ., or .a, or .b, etc.; if he is trying to use 9 as an md value, that won't work, he has to be using one of Stata's md values). Plus, it did work for me! So, my guess is that either (a) he is using some earlier version of Stata which does not support this variation of the cond command, or (b) he's not using one of Stata's md values, e.g. he is using 9 for md when Stata wants ., .a, etc.

In any event, it only takes one additional line of code to fix, but it seems like the command as originally written should work except under the conditions I have just mentioned.



-------------------------------------------
Richard Williams, Associate Professor
OFFICE: (574)631-6668, (574)631-6463
FAX: (574)288-4373
HOME: (574)289-5227
EMAIL: [email protected]
WWW (personal): http://www.nd.edu/~rwilliam
WWW (department): http://www.nd.edu/~soc

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

--

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Michel Camus, Ph.D.

�pid�miologue, Div. Biostatistique et �pid�miologie, DGSESC, Sant� Canada

Epidemiologist, Biostatistics and Epidemiology Div., HECSB, Health Canada

Courriel / e-mail : [email protected] <mailto:[email protected]>

T�l�phone / phone : (514) 850-0157

T�l�copieur / fax : (514) 850-0836

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~




*
* 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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index