I don't disagree that it can often be done other ways if one looks hard
enough, but there are definitely times where it would be nice to write a
function to do quick things over and over, particularly where a function
relates to locals and thus requires at least two lines were it written as a
Stata command (one to call the function, one to assign the returned value to
a local). I'm not sure I entirely agree with the heirarchy that you've set
up, however, in that I don't know that moving a feature from a command to a
function necessarily represents a "promotion." It's certainly a different
way of doing things, but whether it's better or not entirely depends on the
context.
Given that I've conceded that most things can be done other ways, I'm going
to have to decline your challenge. The only statement I will make to that
effect aside from the aforementioned 'doing simple modifications of locals
in-line' is that a more complete implementation of regular expressions would
be helpful. A comparison to Perl leaves Stata's implementation rather
humbled--and, although it's not necessarily fair to take the strongest
feature of one language and compare it to one of the weaker features of
another, nevertheless in day-to-day use powerful regular expressions are
wonderful things to have in one's arsenal.
Best,
Ari
>>>>>>>>>>
Date: Thu, 25 Jan 2007 23:06:39 -0000
From: "Nick Cox" <[email protected]>
Subject: RE: st: Padding zeros, writing functions
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.
*
* 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/