-nmissing- is a user-written command,
last published in Stata Journal 3(4)
2003, so far as I can see.
-tabstat- is an official Stata command.
What you tried cannot be expected to
work. The -s()- option of -tabstat- just
accepts items from a menu indicating statistics
to be calculated within -tabstat-. What
you tried would only work in these
circumstances: that if -tabstat- didn't
recognise what you asked for, it then
would try to find a command with the
same name and use its results in tabulation.
I see that this idea makes sense from your point
of view, but it is essentially impossible to program
without knowing what kinds of results
would be returned by the program called, and
arguably it is bad design in any case.
However, what you want would be
possible to program in a different way, if
StataCorp were to extend the set of statistics
provided to include the number of missing
values. That would, however, require some
restructuring of -tabstat- and arguably it
is, again, bad design in any case, the main
point being that -tabstat- has a clear focus
as a wrapper for -summarize-.
Loosely similar comments apply to -tabulate-
and -table-.
A cruder alternative is to cut and paste
output from -nmissing- to go alongside
outpot from -tabstat-. Clearly that is
not a very attractive solution.
A better alternative is to learn to
use -tabdisp- to get what you want. In
your example, the code might look like
egen n = sum(1), by(DURSTAY DETMETH)
egen nmissing, sum(mi(WEEKDELAY)), by(DURSTAY DETMETH)
egen mean = mean(WEEKDELAY), by(DURSTAY DETMETH)
tabdisp DURSTAY DETMETH , c(mean n nmissing)
There is some discussion of related problems
in
Problems with tables, Part I. Stata Journal
3(3):309--324 (2003)
Nick
[email protected]
A.M. Vos
> I just found 'nmissing' and I hoped it was possible to use that in
> combination with
> tabstat, but it appeared not to. For instance, my syntax reads:
>
> by DURSTAY DETMETH: tabstat WEEKDELAY, s(mean n)
>
> and I would like to say:
>
> by DURSTAY DETMETH: tabstat WEEKDELAY, s( mean n nmissing)
> that is, for each combination of durstay and detmeth
> obtaining the mean
> delay in
> weeks, the number of observations on which the mean was
> calculated, and
> the number
> of observations with a missing value on weekdelay.
>
> it would also be nice if 'nmissing' could be used in combination with
> table and tabulate.
> would this be possible?
*
* 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/