Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, is already up and running.

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

st: Re: Queries about -cond()

From   Maarten Buis <>
Subject   st: Re: Queries about -cond()
Date   Mon, 29 Oct 2012 10:28:59 +0100

On Sun, Oct 28, 2012 at 2:32 AM,  <> 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:

> 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
Reichpietschufer 50
10785 Berlin
*   For searches and help try:

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