Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: the -missing- command


From   [email protected] (Jeff Pitblado, StataCorp LP)
To   [email protected]
Subject   Re: st: the -missing- command
Date   Mon, 10 Oct 2005 16:34:25 -0500

louis boakye-yiadom <[email protected]> asks about the -missing()- function:

> I have two questions regarding the -missing- command (or function?).

> First question:
> I'm not clear about exactly what -missing- does. An example will clarify my 
> concern. I have a dataset containing 11 variables (the first is -clust- and 
> the last is -s11aq13-). One of the variables is -trexpcd-, and the total 
> number of observations is 4872. I gave the following commands and had the 
> shown output:

> count if mi(trexpcd)
> 4649
> count if mi(clust-s11aq13)
> 82

> My understanding of the online -help- is that -missing- evaluates the number 
> of observations for which any of the arguments is missing. So, for the 
> second command, since -trexpcd- is one of the arguments, I expected the 
> result to be a number which is at least equal to 4649.

> Can anyone please show me what I'm missing?

> Second question:
> Also, I had the following result:
> count if !mi(clust-s11aq13)
> 4790

> Does !mi() evaluate the number of observations for which none of the 
> arguments is missing? Thank you.

I believe what Louis wants is Nick Cox's -nmissing- command, which (among
other things) reports the number of missing values found in the variable of
the dataset:

	. ssc install nmissing
	(output omitted)

	. sysuse auto
	(1978 Automobile Data)

	. nmissing

	rep78		5

	.

There is also a companion command called -npresent- that reports the number of
non-missing values found in each variable of the dataset:

	. npresent

	make               74
	price              74
	mpg                74
	rep78              69
	headroom           74
	trunk              74
	weight             74
	length             74
	turn               74
	displacement       74
	gear_ratio         74
	foreign            74

Also, look into the -mark- and -markout- commands.  They help you generate a
variable that indicates observations that are free of missing values for a
specified list of variables:

	. mark touse

	. markout touse price-foreign

	. count if touse
	   69

Svend Juul <[email protected]> also replied and was puzzled by the results of the
following commands:

	. count if missing(rep78-headroom)
	    5

	. count if missing(mpg-headroom)
	    0

-missing()- is a function, in this context "rep78-headroom" is interpreted
to mean the difference between the variables -rep78- and -headroom-.

--Jeff
[email protected]
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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