Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: a question on how to create a complex loop


From   Aluko Hope <aluko.hope@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: a question on how to create a complex loop
Date   Wed, 8 Feb 2012 11:00:53 -0500

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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index