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

# st: Re: Queries about -cond()

 From Maarten Buis To statalist@hsphsun2.harvard.edu Subject st: Re: Queries about -cond() Date Mon, 29 Oct 2012 10:28:59 +0100

```On Sun, Oct 28, 2012 at 2:32 AM,  <pham@ri.ncgm.go.jp> 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<.

-- Maarten

---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl
---------------------------------
*
*   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/
```