help lookfor_all              Michael Lokshin, Zurab Sajaia, and Dan Blanchette
-------------------------------------------------------------------------------

Title

lookfor_all -- Searches for variables/patterns in Stata data files (.dta)

Syntax

Searching within current directory

lookfor_all pattern[pattern [...]] [, options]

where pattern is a word that could be a name (or part of the name) of the variable and/or a word (or part of a word) in the variable label or value label name or value label if the vlabs option is specified or a word (or part of a word) in a note attached to the dataset or a word (or part of a word) in a note attached to a variable if the notes option is specified. lookfor_all only does case insensitive searches so searching for "test" may find "Test", "TEST", or "tESt" as well as "test".

Searching within current directory and subdirectories

lookfor_all pattern[pattern [...]] [, subdir options]

options Description ------------------------------------------------------------------------- Main

directory(path) an option to specify the root directory where to search subdir an option for searching subdirectories describe an option to format the output codebook another option to format the output vlabs also search value label names and value labels notes also search patterns in dataset notes and variable notes dnotes also search patterns in dataset notes vnotes also search patterns in variable notes

Advanced

maxdepth(integer > 1) an option to specify how far down a directory tree to search maxvvar(integer) an option for Stata SE or Stata MP users to allow lookfor_all to open a dataset with up to 32,767 variables dirfilter(regular expression) an option to specify a regular expression pattern that the subdirectory name has to satisfy in order to search files in that directory. filter(regular expression) an option to specify a regular expression pattern that the file name has to satisfy in order to search the file.

Description

lookfor_all is an extension of the Stata program lookfor. lookfor_all searches through all Stata data files in a current directory and subdirectories for the variable(s) with at least one of the specified patterns. Each pattern could be a part/whole variable name and/or a word (part of the word) in the variable label. lookfor_all outputs the list of data files where the pattern was found and the list of variables within every data file that match the pattern. The files listed are clickable. By clicking on the file, Stata loads that data file into memory. lookfor_all can also search a directory other than the current directory by specifying the directory(path) option for a search.

Options

+------+ ----+ Main +-------------------------------------------------------------

directory(path) specifies the path where lookfor_all should start searching. By default lookfor_all searches files in the current directory.

subdir if specified lookfor_all searches through all Stata data files (.dta) in the current directory and subdirectories or the specified directory and its subdirectories. If this option is not specified lookfor_all searches only within the files in the current directory or the specified directory.

describe controls the way the variables that match the pattern are outputted. By default lookfor_all outputs the variables following the name of the data file they are in. Specifying describe makes Stata run the describe command on the variables that were found. You can control the output using the options of the Stata command describe. These options are simple short details fullname numbers.

codebook controls the way the variables that match the pattern are outputted. Specifying codebook makes Stata run the codebook command on the variables that were found. The output will be the number of unique observations, mean, minimum, maximum and the label of the matching variables. You can control the output using the options of the Stata command codebook.

vlabs if specified lookfor_all will also search through the value label names and value labels.

notes if specified lookfor_all will also search through the notes attached to dataset > s and variable notes. Using this option is the same as specifying both options: dnotes and vnotes{p_end}

dnotes if specified lookfor_all will also search through the notes attached to dataset > s.{p_end}

vnotes if specified lookfor_all will also search through the notes attached to variabl > es.{p_end}

+----------+ ----+ Advanced +---------------------------------------------------------

maxdepth(integer > 1) if specified lookfor_all will only search through all Stata data files (.dta) as far down as the positive integer value that is specified. If subdir is not specified and maxdepth is, then it is assumed subdirectories should be searched.

maxvvar(integer 4000) if specified and you are using Stata SE or MP, lookfor_all will temporarily set maxvar to whatever positive integer is specified. The maximum value is 32767. This allows lookfor_all to search a dataset that contains more variables than maxvar is currently set to be able to open. Changing the setting of maxvar will stop the page up key from being able to access command history. So if you set maxvar to some high value (up to 32767) yourself before running lookfor_all, lookfor_all will not need to set it and you will be able to access your command history with the page up key after running lookfor_all.

dirfilter(regular expression) if specified lookfor_all will only search through all Stata data files (.dta) in the current directory or specified directory and only subdirectories that satisfy the regular expression pattern.

filter(regular expression) if specified lookfor_all will only search through Stata data files (.dta) that satisfy the regular expression pattern.

Examples of searching within the current directory

. lookfor_all edu

. lookfor_all edu, describe simple

. lookfor_all edu, de short

Examples of searching the current directory and sub-directories

. lookfor_all edu, sub

. lookfor_all edu, maxdepth(3) de fullnames

. lookfor_all edu, sub codebook vlabs

. lookfor_all edu, dirfilter(data) codebook

Examples of searching the specified directory

. lookfor_all edu, sub de dir("c:\data\")

. lookfor_all edu, sub de dir("c:\data\") filter(^wave1)

Authors

Zurab Sajaia The World Bank zsajaia@@hotmail.com

Michael Lokshin The World Bank mlokshin@@worldbank.org

Dan Blanchette The Carolina Population Center University of North Carolina - Chapel Hill, USA dan_blanchette@unc.edu

Note Useful suggestions and feedback by Phil Bardsley and Michael Norman Mitchell ar > e gratefully acknowledged.

Also see

Online: lookfor, describe, and codebook