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

st: RE: CREATING MUTUALLY EXCLUSIVE MULTILEVEL CATEGORICALVARIABLE


From   "Leonard Egede" <[email protected]>
To   <[email protected]>
Subject   st: RE: CREATING MUTUALLY EXCLUSIVE MULTILEVEL CATEGORICALVARIABLE
Date   Wed, 21 Jul 2004 08:33:06 -0400

Nick,
 
ran the code and i get the message below
 
gen ndiseases = hyt + hrt + jtn + srk + pulm + ren
 
 
.. gen status = 0 if ndiseases == 0 
(11532 missing values generated)
 
 
.. tokenize "hyt hrt jtn srk pulm ren"  
 
 
.. forval i = 1/6 { replace status = `i' if ``i'' == 1 & ndiseases == 1 } 
==1 invalid name
r(198);
 
end of do-file
r(198);
 
leonard



>>> [email protected] 07/19/04 05:13AM >>>
I am not clear on your data structure. 

One natural data structure would be seem to be to hold 
information on A through F as indicator variables, 1 for has and 
0 for has not condition. 

gen ndiseases = A +  B +  C +  D +  E +  F

counts diseases. Then 

gen status = 0 if ndiseases = 0 

tokenize "A B C D E F" 

forval i = 1/6 { 
	replace status = `i' if ``i'' == 1 & ndiseases == 1 
} 

replace status = 7 if ndiseases > 2 & ndiseases < . 
assert status < 8 

Nick 
[email protected] 

Leonard E. Egede MD, MS
 
> I am trying to create a categorical variable with 8 levels 
> each representing the presence of one of six discrete disease 
> conditions. However, it is possible for subjects to have more 
> than 1 disease condition. How do I create such a multi-level 
> variable so that each level contains only subjects with 1 of 
> the disease conditions and those with multiple disease 
> conditions fall into a level and those with none of the 
> diseases of interest fall into another level?
> 
> I tried the generate and replace commands as shown below but 
> i am uncertain of how stata handles arguments in the replace command
> 
> ***What i have done so far***
> I created a multi-level variable using generate and replace 
> capture discrete medical conditions with 7 categories as follows
> generate disease
> replace disease=2 if medical condition ==A
> replace disease=3 if medical condition ==B
> replace disease=4 if medical condition ==C
> replace disease=5 if medical condition ==D
> replace disease=6 if medical condition ==E
> replace disease=7 if medical condition ==F
> 
> The questions are - is this the right method? if so  how do i 
> code subjects with more than 1 of the conditions above i.e 
> any combinations of A thru F. Also, how does this approach handle
> people with 2 or more of the specified conditions.
> 
> I intend to use the 8 level variable in a logistic model with 
> level 1 (those without diseases of interest) as the reference.

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


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