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

Re: st: Re: tabulating and summarising


From   Kim Price <[email protected]>
To   [email protected]
Subject   Re: st: Re: tabulating and summarising
Date   Fri, 10 Jan 2003 10:14:12 -0500

I realize that the repetition is cumbersome, however I wanted a way to check each step as it was performed so I could see any problems.

In response to your questions:

1) Each respondent may have up to five of 26 distinct chronic conditions that are spread across five variables.

2) I need a way to collect the total for each of the 26 chronic conditions across the entire sample (so I can look at each of the chronic conditions independently rather than each sub set of responses).

Thanks,
Kim

On Friday, January 10, 2003, at 08:58 AM, baum wrote:


Not sure just what you want the end result to be, but all these repetitive statements are surely not necessary...

local nchron 3
gen cc=.
forval i=1/5 {
forval j=1/`nchron' {
replace cc=`j' if chron`i'cat == `j'
}
}

but that will give you one outcome variable which will merely have the highest value of chron?cat for that observation. To answer the question, please make clear
(1) how many possible values there are (nchron above)
(2) what the outcome should be -- one variable, several variables (e.g. can the patient be suffering from more than one chronic condition?)

Thx
Kit
_______________________________________________________________________ _
Christopher F Baum, Boston College Economics, Chestnut Hill MA 02467 USA
[email protected] http://fmwww.bc.edu/ec/baum.php


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


--On Friday, January 10, 2003 2:33 -0500 Kim wrote:


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