[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Should be simple yet ... how to write a function?
On Feb 18, 2009, at 4:03 AM, Fabrice wrote:
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.
You don't, at least not in Stata. You can write a function for use
with -egen-, however, while some users have gotten a lot of mileage
out of this, most people who ask about writing their own functions are
looking to make use of them in contexts where -egen- won't help.
Note that you *can* write your own functions in Mata. Moreover,
depending on what you're doing, Mata may offer other advantages as
well (e.g., speed).
-- Phil
*
* 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/