Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: RE: a question on how to create a complex loop
From
Reinhardt Jan Dietrich <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: RE: a question on how to create a complex loop
Date
Wed, 8 Feb 2012 16:22:24 +0000
You could transpose the data into wide format using reshape (type: help reshape to see the code). Then you will get diagcateg1, diagcateg2, etc., i.e. a variable for each measurement point/occasion.
Then generate a new variable
Gen diagcat_count = diagcateg1 + diagcateg2
usw.
Best
Jan
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Aluko Hope
Sent: Mittwoch, 8. Februar 2012 17:01
To: [email protected]
Subject: st: a question on how to create a complex loop
Dear Stata list users,
I am a health services researcher who is relatively new to STATA and I
am trying to count the number of times each patient satisfies a
particular criteria. I think I need to do this by creating a complex
loop but I am stuck as to how to go about it.
The data is structured in the following manner:
id diag1 diag2 diag3 visit# diagcateg1
1 icd icd icd 3 1
1 icd icd icd 3 1
1 icd icd icd 3 1
2 icd icd icd 4 0
2 icd icd icd 4 0
2 icd icd icd 4 0
2 icd icd icd 4 0
3 icd icd icd 2 1
3 icd icd icd 2 1
the icd refer to really icd9 and the diagcateg1 is a binary variable
that already classifies certain icd9 into categories.
in words, what i want to do now is:
whenever diagcategory is 1, count the number of times per patient (id)
that there is a diag1 diag2 or diag3 that fit a particular criteria. i
would be happy with the total number per patient but would ideally
like to be able to describe the total number per patient per visit.
Please help,
Many thanks in advance,
Aluko Hope
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/