Module to check whether a variable exists or not in a dataset.
checkfor2 anything [, tolerance(#) table nolist nosum genmiss(newvarname) missing(string)]
checkfor2 is a data management routine to check for existence of variables within a (usually big) data set.
checkfor2 searchs through the data whether each variable exists. The variables are clustered between unavailable variables, available variables with a little amount of missing values and available variables with too many missing values.
isvar must be installed (ssc install isvar).
anything is composed of variable names or lists of variables,
tolerance is the tolerance level (in percentage) to consider a variable as available, with default 0,
nolist avoids displaying availability status at the end of the process,
nosum avoids displaying summary statistics of available variables,
table displays the results in a table (instead as text),
genmiss creates a new variable containing the number of missing values among the available variables,
missing defines a specific value or string considered as a missing value.
r(unavailable) names of unavailable variables.
r(available) names of available variables with a small amount of missing values.
r(manymissings) names of variables present but with too missings.
. use mydata, clear
. checkfor2 x y z , mis(99) genmiss(countmiss)
. su `r(available)'
. tab countmiss
. u bigdataset in 1/100, clear // Big data set
. checkfor2 v1 v2 v3 xx yy , nosum tol(5) tab
. use `r(available)' using bigdataset, clear
checkfor2 and its primary version (checkfor) have been primarily written for comparable surveys such as the Demography and Health Surveys (DHS) or the Multiple Indicator Cluster Surveys (MICS). But this could easily applied to any other survey.
Amadou Bassirou DIALLO. Poverty and Health Division, PREM, The World Bank. Email: firstname.lastname@example.org
Jean-Benoit HARDOUIN. Regional Health Observatory of Orléans, France. Email: email@example.com
We would like to thank Christophe Rockmore and also Nick Cox and Kit Baum for their comments.
Online: help for checkfor, isvar, nmissing, npresent, missing and dropmiss if installed.