Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: -findname- available from SSC
"Nick Cox" <firstname.lastname@example.org>
st: -findname- available from SSC
Wed, 31 Mar 2010 13:52:14 +0100
Thanks to Kit Baum, a new program -findname- is available on SSC. Stata
9 is required. To see full details,
. ssc type findname.hlp
. ssc inst findname
-findname- is offered as a user-written alternative to official command
Many long-term members of this list will recall various discussions of
the status of -ds- culminating in the recent announcement by William
Gould on 3 March
that -ds- was being restored to full official status, which was
implemented in the 9 March update to Stata 11 [NB].
Just when you may have thought that matter was now cleared up after a
few years' grumbling from various users, here is something to complicate
What's different? In a way, not much. -findname- has the same main aim
as -ds-, of finding variables that fit specified criteria. But clearly
the differences are what justify a new program.
* Name. A program by any other name would not really be different, but
the name -ds- originally meant "short describe" and this role has long
since been submerged by the finding role. In addition, -describe,
simple- now does what -ds- did originally. -find- is reserved by
statute for StataCorp, and in any case is so good a name that only a
really powerful or general command should be so named. After toying with
-findvars- I decided I liked -findname-. If you want to insist that it
should be -findvarname- or -findvarnames- or -findvarlist-, logic is
firmly on your side.
* Syntax. -ds- has a rather ugly syntax centred on a -has()- option,
which I must have liked when I devised it, but no longer. My guess is
that most users of -findname- will find its syntax less idiosyncratic.
The syntax of -findname- now distinguishes more clearly between e.g.
finding out whether value labels are attached, what they are named, and
what is included in their text.
* Functionality. -findname- has more flexibility, including the ability
to search value label and characteristic text as well as names. Options
-any()- and -all()-, which featured in -ds3- from SSC almost 10 years
ago, have been restored. (Maarten Buis reminded me a while back that
these had not made the cut to official -ds-.) So, for example,
findname, all(@ == int(@))
finds all variables with only integer values. (Any string variables are
just ignored in a call like this.) To give another example,
findname, all(@ == 0 | @ == 1 | @ == .)
is a way of finding all indicator variables, which are always 0 or 1 or
missing. -type(byte)- would only in special cases catch all indicator
variables and only indicator variables.
* Combining options. You can combine options, searching for those
variables with all of two or more criteria satisfied. -findname- finds
the intersection of sets.
* Saving to locals too. That is likely to be handy on occasion in
identifying the union of sets.
* Support for -if- and -in- where appropriate.
That's it, really. I intend to write about the problem of finding
variables and about -findname- in particular in Stata Journal 10(2).
However much you extend the scope of a command like this, there are
always tasks for which you need to write your own code.
* For searches and help try: