[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: Should be simple yet ... how to write a function? |

Date |
Wed, 18 Feb 2009 11:09:57 +0100 |

<> See http://www.stata-journal.com/article.html?article=pr0007 When you -generate- a variable, you implicitly apply a "function" to all observations. If you want to write your own function, -egen- is a good starting point, and this is explored in the article cited above... HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Fabrice Gesendet: Mittwoch, 18. Februar 2009 11:04 An: statalist@hsphsun2.harvard.edu Betreff: st: Should be simple yet ... how to write a function? Im a pretty advanced Stata user, but have a simple question I cant figure out: how does one write a *function*, i.e. a program that returns a value, and that can be called like local y = fct(x), where x and y are numbers or strings. This seems it should be available somewhere in the language, yet I?ve searched in a lot of programming explanations about Stata and never found a way to write that. FYI, I program extensively in stata, know about r-type vs. e-type program, and know how to store results to return to main program. I just don?t know how to write the most simple function form. Any idea? Fabrice * * 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/

**Follow-Ups**:**st: RE: Should be simple yet ... how to write a function?***From:*"Fabrice" <fcaspam@yahoo.fr>

**References**:**st: Should be simple yet ... how to write a function?***From:*"Fabrice" <fcaspam@yahoo.fr>

- Prev by Date:
**st: Should be simple yet ... how to write a function?** - Next by Date:
**Re: st: Should be simple yet ... how to write a function?** - Previous by thread:
**st: Should be simple yet ... how to write a function?** - Next by thread:
**st: RE: Should be simple yet ... how to write a function?** - Index(es):

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