Statalist


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

RE: st: RE: surprising behaviour in -lookfor-?


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: surprising behaviour in -lookfor-?
Date   Tue, 27 Jan 2009 20:49:55 -0000

Jeph's question has had the perhaps unexpected side-effect of
underlining that 

lookfor ,

is an easy way of identifying variables with variable labels including
commas. That's not trivial, as for example commas in variable labels can
be a little problematic in graph titles and they may indicate (at least
in the natural sciences) variables with units of measurement specified
whenever conventions like "length, metres" are used. So there are some
good reasons why you really might want to do that. 

Adding options to -lookfor- or writing variants on -lookfor- with
options would break that kind of example, which you may or may not care
about. 

I am a bit puzzled about David's comment that you may be bitten by
-lookfor- because it looks in variable labels. As that is about half of
what -lookfor- is intended to do, it is not really to be considered a
limitation of -lookfor-.

After all, if you wanted to find just certain kinds of variable name,
there are several ways to do it, including -describe-, -unab- and -ds-. 

-ds-, by the way, can search for variable labels matching patterns (or
their complements) via -ds, has()- or -ds, not()-. 

Nick 
[email protected] 

Jeph Herrin

David Elliott wrote:
 >
 > Note, of course, that -lookfor- can bite you by returning a variable
 > name that has the search string in its label.
 >
 > Options like varonly or labonly would increase -lookfor-'s utility in
 > this context.  I think the second quote by Heinlein below is very
 > apropos...
 >


On reflection, it is only to grab variables with certain
labels that I use -lookfor-; I often get survey data where
there are, eg, 100 variables named q1-q100 and to avoid
renaming the variables I use the labels to distinguish
them. Hence calling -lookfor- to get the subset I want.

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index