This can be tricky at the best of times. At worst,
you expect Stata to take account of data that it
doesn't have. How do you expect it to do that?
More positively, -tabcount- from SSC is one stab
at this problem. -groups- from the same source
is another.
There's a write-up at
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
Nick
[email protected]
Christopher W. Ryan, MD
> I am trying to use Stata to monitor and analyze the types of
> encounters
> that my medical students see in their family medicine course. I use
> ICPC-2 diagnostic codes to classify the encounters (International
> Classification of Primary Care).
>
> I have a dataset with the following variables:
> studentid
> code
> textforcode
> count
>
> It is easy enough to generate a table with students in rows down the
> side, and the ICPC codes in columns across the top, with the cells
> containing the number of times a student has seen that diagnosis:
>
> -table studentid code, contents(sum count)-
>
> My trouble arises with codes that *no* student has seen. With the
> simple table-related commands with which I'm familiar, no column for
> such a code will appear in the table. But there are 10
> diagnostic codes
> that I need to monitor, to make sure every student has encountered at
> least one case of them. So I'd like columns for those ten codes to
> always appear in the table, irrespective of whether anyone saw those
> diagnoses. If no one has seen one of those diagnoses, then
> the cells in
> that column would all contain the number zero.
*
* 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/