Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: -findname- available from SSC


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: -findname- available from SSC
Date   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

To install,  

. ssc inst findname 

-findname- is offered as a user-written alternative to official command
-ds-. 

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 
<http://www.hsph.harvard.edu/cgi-bin/lwgate/STATALIST/archives/statalist
.1003/date/article-173.html> 
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
things again. 

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. 

Nick 
[email protected] 


*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index