| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: re counting missing
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.
I have achieved this by (may be a bit long handed)
by id class5: gen n =_n
by id class5: gen number =_N
by id: gen t=_N
drop if n < number
gen proportion = number/t
format proportion %9.2f
list id group class5 t n number proportion if id <3
+--------------------------------------------------------+
| id group class5 t number propor~n |
|--------------------------------------------------------|
1. | 1 reflux Normal 20 12 0.60 |
2. | 1 reflux synchronous 20 6 0.30 |
3. | 1 reflux High amplitude 20 2 0.10 |
4. | 2 reflux synchronous 12 3 0.25 |
5. | 2 reflux High amplitude 12 1 0.08 |
6. | 2 reflux Failure 12 8 0.67 |
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 example for subject id 2
+--------------------------------------------------------+
| id group class5 t number propor~n |
|--------------------------------------------------------|
| 2 reflux Normal 12 0 0 |
| 2 reflux synchronous 12 3 0.25 |
| 2 reflux High amplitude 12 1 0.08 |
| 2 reflux Failure 12 8 0.67 |
| 2 reflux Ineffective 12 0 0 |
I am unable to achieve this.
Any help would be greatly appreciated.
Richard Hiscock
*
* 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/