quinta-feira, 14 de julho de 2011

Are all variables missing for an observation? A Stata routine to find out!

Have you never needed to know which observations have missing values for all of a given set of variables? Creating health indicators from national surveys, this is frequently an issue. Because if information is missing for all variables, I want to set the indicator for a given observation as missing, and not zero - what happens when you use some Stata functions. And I could not find any ready function to solve this - Stata has only a function that tells me whether any of a set of variables is missing.

So I wrote this "allmiss" command to do that. If it is useful for you, please download the allmiss.ado file and place it in your ado\personal folder. It is ease to use, just type
. allmiss varlist , gen(varname)
and the command will create a new variable varname that is 1 if all variables in your list are missing and zero otherwise. If you omit the generate bit, it will create a variable named _allmiss.

Have fun!