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 |
"Martin Weiss" <martin.weiss1@gmx.de> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: AW: Evaluating a set of conditions |

Date |
Wed, 23 Jun 2010 09:37:23 +0200 |

<> The check for "missing<." strikes me as redundant, as this is a count of missings and will range from 0 to 5 in your example. How could it be missing? Is it really correct to include "a" in your call -egen anytwo = rowtotal(a b c d e), missing-. I thought "a" was supposed to be evaluated separately. HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Thomas Speidel Gesendet: Mittwoch, 23. Juni 2010 01:10 An: statalist@hsphsun2.harvard.edu Betreff: st: Evaluating a set of conditions Following up on my previous post: http://www.stata.com/statalist/archive/2010-06/msg00984.html here is an example for something I am trying to achieve in a nice/efficient/eleganty way. 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 As I said missing values are crucial, especially when evaluating the second condition. My current program works, but I don't think it is efficient and it probably does things that are unnecessary: ******************************************* 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==. ******************************************* I tried to play around with cond, but I found it was making this much more complicated then it is. I know I am complicating my life more than I need to which is why I am looking for alternative solutions. -- 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/ * * 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/

**References**:**st: Evaluating a set of conditions***From:*Thomas Speidel <thomas@tmbx.com>

- Prev by Date:
**Re: st: what the equavilent command of estimates store for mim: gllamm models** - Next by Date:
**AW: st: xttrans accuracy** - Previous by thread:
**st: Evaluating a set of conditions** - Next by thread:
**st: RE: Evaluating a set of conditions** - Index(es):