Anyone watching: when we say -function-,
we really do mean -function- in Stata's strict
sense. A function is not a command, but something
like -log()- or -substr()-.
In principle, this is a gap. In practice,
what are you missing?
In principle, what is nice about functions
includes the way in which you can combine them,
especially but not only in what you feed to
-generate- and -replace-. Stuff like
exp(mean + sd * invnorm(uniform()))
or
real(substr(string(floor(<number>)),-2,2)
can be powerful, concise and even moderately
readable. But apart from that, I assert that
what you want can usually be done otherwise,
by a combination of existing functions, -egen-
functions, or commands. Or if that's not true
you would really rather than StataCorp did it,
because the function should be coded extremely
carefully in C.
In terms of evidence for this assertion:
scan the list of
-egen- functions, official and user-written,
to see what really deserves to be promoted to
a Stata function.
Or here's a challenge: if
your statement is true, you should be able
to name a few functions that are missing from
Stata.
In my Stata programming, I can think of only
one program I've written that really was an
awkward substitute for a function, i0kappa.ado
on SSC. And next time round it will be
rewritten in Mata anyway.
Nick
[email protected]
Ari Friedman
> Thanks Svend. That does what I was looking for.
> And thanks Nick. Your answer was (as always) most informative, if
> depressing in this case. User-written functions would be
> useful on those
> rare occasions when Stata doesn't already have a built-in or
> user-written
> way of achieving the desired effect.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/