Monday, February 27, 2006

st: tables to include columns for observations that are not present

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.

Any suggestions how to do this?

Thanks. -- Christopher W. Ryan, MD SUNY Upstate Medical University Clinical Campus at Binghamton and Wilson Family Practice Residency, Johnson City, NY cryanatbinghamtondotedu GnuPG and PGP public keys available at

"If you want to build a ship, don't drum up the men to gather wood, divide the work and give orders. Instead, teach them to yearn for the vast and endless sea." [Antoine de St. Exupery]

* * For searches and help try: * * *


Links to this post:

Create a Link

<< Home

This page is powered by Blogger. Isn't yours?