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