Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Thomas Speidel <thomas@tmbx.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Evaluating a set of conditions |

Date |
Tue, 22 Jun 2010 17:09:57 -0600 |

I have a number of dummies: a, b, c, d, e (missing values do exist) Disease=true if the following conditions are met: 1) a must be true AND 2) any two of b, c, d, e are true

******************************************* egen anytwo = rowtotal(a b c d e), missing egen missing = rowmiss(a b c d e) replace anytwo = . if (anytwo==0 & missing>=2 & missing<.) replace anytwo = . if (anytwo==1 & missing==1) replace anytwo = . if (anytwo==1 & missing==3) replace anytwo = . if (missing>=4) gen disease = 1 if (a==1 & anytwo>=2 & anytwo<.) replace disease = 0 if (a==1 & anytwo<2) replace disease = 0 if a==0 replace disease =. if a==. *******************************************

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

**Follow-Ups**:**st: RE: Evaluating a set of conditions***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**st: AW: Evaluating a set of conditions***From:*"Martin Weiss" <martin.weiss1@gmx.de>

- Prev by Date:
**Re: st: Poll of polls** - Next by Date:
**Re: st: Poll of polls** - Previous by thread:
**Re: st: Evaluating a set of conditions** - Next by thread:
**st: AW: Evaluating a set of conditions** - Index(es):