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

st: Re: summarising and tabulating

From   baum <>
Subject   st: Re: summarising and tabulating
Date   Sat, 11 Jan 2003 11:42:20 -0500

--On Saturday, January 11, 2003 2:33 -0500 Nick wrote:

Your variables chron?cat are in effect a data matrix.

There are various possible approaches to that. The
simplest without using any user-written software
is to -reshape- your data to long. See [R] reshape
and also

First, make sure that your data set is -save-d

Second, you need to -rename- those variables
to a stub plus suffix form.

foreach v of var chron?cat {
	rename chron`v'cat chroncat`v'

Now I assume you have a patient id somewhere.
If not, create one:

gen id = _n


reshape long chroncat , i(id) j(time)

I am here guessing that 1 2 3 4 5 refer
to different times. If not, you can
supply a sensible name.

Now you should get the information
you want from

tab hroncat time
It seems to me that if you keep this 'wide' you would want 26 variables (as Lee suggested could be created by egen) rather than 5. Unlike Nick, I took the five to mean not measurements over time, but the answer to a multipart question such as 'do any of these cc's really trouble you? If so which one is the most troublesome?', 'which one is the next most troublesome'...'list up to five that affect you' all at one point in time. If that is what you have, then you do not care where the condition appears, perhaps (unless they are truly ordered in terms of severity), and you would just want to do 'tab chroncat' after making the data long, following Nick's suggestions.


Christopher F Baum, Boston College Economics, Chestnut Hill MA 02467 USA

* For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index