Find that variable fast with -lookfor-

Looking for a certain variable in a dataset with so many variables, even if you yourself have created these variables, can sometimes test your patience. Use -lookfor- to minimize that stress. But, if in the first place you have created variable names and variable labels that do not make sense—for example, v1 with label “variable 1“—you deserve that stress!

-lookfor- is like Ctrl+f in some applications. It helps you find the variables whose names or labels (or a part of their names or labels) match your string search criteria. -lookfor- searches for any match in all variable names and labels in the dataset and returns the list of resulting variable names and their corresponding descriptions. Example:

sysuse census.dta, clear
lookfor pop
lookfor POP
lookfor census

Notice that -lookfor- is not case sensitive—looking for “pop” is the same as looking for “POP.” Alternately, to look for all occurrences of “pop” or “census,” you may type:

lookfor pop census

See “help lookfor” for more.

2 Responses

  1. also, check “lookforit” and “wherefor”, which offer some extra features

  2. Also, check out the more recent program -lookfor_all- (from SSC).

    – Eric

Leave a Reply