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

st: RE: ? loop


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: ? loop
Date   Wed, 15 Oct 2003 14:54:08 +0100

Mr J Saravana Ganesh FRCS(Ed. & Glasg.)

> I have data on various immunosuppression therapies coded as 
> 1 or 2 or missing(eg given below), where 1=no and 2=yes.
> 	+---------------------------------------+
> 	cya   aza   pred2   okt_p   mmf   tli 
> 	---------------------------------------
> 1.	2     2       2       1     1     1 
> 2.	2     2       2       1     1     1 
> 3.	2     2       2       .     1     . 
> 4.	2     2       2       1     1     1 
> 5.	2     2       2       1     1     1 
> 	---------------------------------------
> 6.	2     2       2       1     1     1 
> 7.	2     2       2       1     1     1 
> 8.	2     1       2       1     2     1 
> 9.	2     2       2       1     1     1 
> 10.	2     2       2       1     1     1 
> 	+---------------------------------------+
> I need to summarise this into a variable by patients 
> receiving 1 or 2 or 3 or more type of drugs into a 
> variable. Say all patients in the above example dataset 
> will be receiving 3 drugs, with information on the missing 
> being omitted.  Any pointers or help will be appreciated.

This could be classified as a question on multiple responses 
in the sense of http://www.stata.com/support/faqs/data/multresp.html

If you just want to count therapies used, 

egen ntherapies = neqany(cya aza pred2 okt_p mmf tli), val(2) 
tab ntherapies 

If you want to keep track of which are used, 

gen therapies = "" 
foreach v of var cya aza pred2 okt_p mmf tli { 
	replace therapies = therapies + "`v'" if `v' == 2 
} 

tab therapies 

Nick 
[email protected] 

*
*   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/



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