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

From |
Nicola Orsini <Nicola.Orsini@ki.se> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: ifelse mata function |

Date |
Tue, 12 May 2009 13:20:40 +0200 |

Mata users,

http://www.iiap.res.in/astrostat/School07/R/library/base/html/ifelse.html

Here is a simple example mata mata clear y = runiform(10,1) x = runiform(10,1) z = J(10,1,.) for (i=1; i<=rows(y); i++) { if (y[i]>= x[i]) z[i] = y[i]-x[i] else z[i] = x[i]-y[i] } y, x, z end Wouldn't be great to have a mata function like -ifelse-? ifelse(y>=x, z=y-x, z=x-y) Nicola * * 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: ifelse mata function***From:*philippe van kerm <philippe.vankerm@ceps.lu>

- Prev by Date:
**st: ANOVA analysis: Probability value as scalar?** - Next by Date:
**st: RE: ifelse mata function** - Previous by thread:
**st: ANOVA analysis: Probability value as scalar?** - Next by thread:
**st: RE: ifelse mata function** - Index(es):

© Copyright 1996–2016 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |