Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Re: Queries about -cond()


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Re: Queries about -cond()
Date   Mon, 29 Oct 2012 09:50:16 +0000

Pham is confusing

missing(a) | missing(b) | missing(c) | missing(d)

with

missing(a|b|c|d)

Here | is the logical "or" operator.

In the second case the result of a logical evaluation a|b|c|d is
always true or false (1 or 0). It can never be missing.

The first case is what is wanted, and it can also be written

missing(a, b, c, d)

The two cases are quite different to Stata.

Negation makes no difference to that difference, but just flips true and false.

On Mon, Oct 29, 2012 at 9:28 AM, Maarten Buis <[email protected]> wrote:
> On Sun, Oct 28, 2012 at 2:32 AM,  <[email protected]> wrote:
>> My emails sent to Statalist have been bounced, and I could not fix the problem.
>> That's why I'd like to ask you personally.
>
> There are several tips on how to troubleshoot such problems here:
> <http://www.stata.com/support/faqs/resources/statalist-faq/>
>
>> Thank you for your helpful suggestions to my problem last time. I again
>> have the same matter with additional conditions to create an indicator
>> using -cond() or equivalence. The problem is as follows:
>> I want to create a variable (h_bp) taking values (1,0 & .) with the
>> following conditions:
>>
>> h_bp is defined  if sbp>=140 or dbp>=90 or curr_dg==1 or past_bp==1
>> (curr_dg & past_bp are binary variables coded as 1,0 or.; the remainder
>> are continuous variables containing . )
>>
>> I tried to write: gen h_bp =cond(sbp>=140
>> |dbp>=90|curr_dg==1|past_bp==1,1,0) if  !mi(sbp|dbp|curr_dg|past_bp)
>
> if !mi(sbp,dbp,curr_dg,past_bp)
>
>> But, h_bp resulted in 1 and 0 without missing value
>>
>> I tried another command suggested by Nick:
>> gen h_bp=sbp>=140 |dbp>=90|curr_dg==1|past_bp==1
>> if sbp<.|dbp<.|curr_dg<.|past_dg<.
>> Then h_bp also resulted in 1,0 without missing value
>
> if sbp<. & dbp<. & lurr_dg<. & past_dg<.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index