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

st: RE: compiling observations across variables


From   Lee Sieswerda <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: compiling observations across variables
Date   Fri, 10 Jan 2003 10:17:52 -0500

It is a little difficult to be sure what you are asking. How many times
could the same chronic condition be listed for the same case? I think you
might be looking for -egen, neqany- or -egen, eqany-. These functions will
generate, alternatively, the number of times a condition occurs, or an
indicator of whether a condition occurs at least once, in a series of
variables. If, for each case, the conditions are not repeated across the 5
variables, and if, for each case, you just want to know if a particular case
occurs across at least once across the 5 variables, you can generate a dummy
variable for each condition.

forvalues x=1/5 {
	egen cc`x' = eqany(chron1cat-chron5cat), values(`x')
}
summ cc1-cc5

Or maybe I'm not completely clear as to what you want to do....


Lee Sieswerda, Epidemiologist
Thunder Bay District Health Unit
999 Balmoral Street
Thunder Bay, Ontario
Canada  P7B 6E7
Tel: +1 (807) 625-5957
Fax: +1 (807) 623-2369
[email protected]
www.tbdhu.com


> -----Original Message-----
> From:	Kim Price [SMTP:[email protected]]
> Sent:	Thursday, January 09, 2003 5:54 PM
> To:	[email protected]
> Subject:	st: compiling observations across variables
> 
> Hi, 
> 
> I have 5 variables that list chronic conditions and I need to tally the
> conditions across the variables.  First I tried generating a dummy
> variable and replacing it with each subset of chronic categories across
> the five variables and then by creating each separately and recoding them,
> however these approaches did not yield accurate results.  After looking in
> the reference manuals and on-line I tried both the sum and count commands,
> however they are also not presenting accurate totals either.  I've
> enclosed excerpts from my Do-files using both the dummy variables and
> "count" command.   
> 
> Any help will be greatly appreciated. 
> 
> Thanks, 
> Kim 
> 
> Using a dummy variable: 
> 
> #delimit ; 
> gen cc=.; 
> 
> replace cc=1 if chron1cat==1; 
> replace cc=1 if chron2cat==1; 
> replace cc=1 if chron3cat==1; 
> replace cc=1 if chron4cat==1; 
> replace cc=1 if chron5cat==1; 
> 
> replace cc=2 if chron1cat==2; 
> replace cc=2 if chron2cat==2; 
> replace cc=2 if chron3cat==2; 
> replace cc=2 if chron4cat==2; 
> replace cc=2 if chron5cat==2; 
> 
> replace cc=3 if chron1cat==3; 
> replace cc=3 if chron2cat==3; 
> replace cc=3 if chron3cat==3; 
> replace cc=3 if chron4cat==3; 
> replace cc=3 if chron5cat==3; 
> 
> and so forth.... 
> 
> Using a dummy variable and recoding: 
> 
> #delimit ; 
> gen cc=.; 
> 
> replace cc=1 if chron1cat==1; 
> replace cc=2 if chron2cat==1; 
> replace cc=3 if chron3cat==1; 
> replace cc=4 if chron4cat==1; 
> replace cc=5 if chron5cat==1; 
> 
> replace cc=6 if chron1cat==2; 
> replace cc=7 if chron2cat==2; 
> replace cc=8 if chron3cat==2; 
> replace cc=9 if chron4cat==2; 
> replace cc=10 if chron5cat==2; 
> 
> and so forth... 
> 
> recode cc  
> 1/5=1  
> 6/10=2  
> 
> and so forth... 
> 
> Using count (I followed a similar format using sum): 
> 
> count if chron1cat==1 | chron2cat==1 | chron3cat==1 | chron4cat==1 |
> chron5cat==1; 
> /*1 "Nervous system" */ 
> count if chron1cat==2 | chron2cat==2 | chron3cat==2 | chron4cat==2 |
> chron5cat==2; 
> /* 2 "Headache/migraine" */ 
> count if chron1cat==3 | chron2cat==3 | chron3cat==3 | chron4cat==3 |
> chron5cat==3; 
> /* 3 "Problems with vision" */ 
> 
> and so forth...
*
*   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