In addition to other answers, -groups- and -tabcount-
from SSC are pre-existing programs on SSC that deal
with various aspects of the problem. For some
discussion, see
SJ-3-4 pr0011 . . . . . . . . Speaking Stata: Problems with tables, Part II
Q4/03 SJ 3(4):420--439 (no commands)
reviews three user-written commands (tabcount, makematrix,
and groups) as different approaches to tabulation problems
It helps to be careful about terminology. In Stata
"missing" connotes missing value(s) within observation(s)
on one or more variables. Counting missings is easy.
The problem here is recording absences, i.e. failure
to appear in the dataset or that part of it being analysed.
It is also possible to do this graphically. For example,
in a bar chart, you just add extra points to the appropriate
axis.
sysuse auto, clear
bysort rep78 : gen frequency = _N
egen tag = tag(rep78)
twoway bar freq rep78 if tag, ///
horizontal barw(0.5) bcolor(none) blcolor(black) ///
yla(1/5 6 "excellent" 7 "spectacular", ang(h) noticks) || ///
scatter rep78 freq, ms(none) mla(freq) mlabpos(9) xsc(off) legend(off)
Nick
[email protected]
Sergiy Radyakin
...
Svend Juul
...
Richard Hiscock
> > In study of swallowing I have oesophageal pressures measured
> > many times on each patient and within patients these are
> > coded into one of 5 contraction types. Subjects may have none
> > up to all of the types of contraction & many or no pressures
> > measured for each type.
> >
> > I wish to count the number of pressures readings measured for
> > each type of contraction for each patient.
> > In examining the data I wish to look at the distribution of
> > proportion within each class5 category. To do this I need
> > to record zero in the proportions for class5 categories that
> > did not occur within a subject.
*
* 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/