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

Re: st: Newbie: Case selection problem


From   Taavi Lai <taavi.lai@ut.ee>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Newbie: Case selection problem
Date   Sat, 05 Feb 2005 17:43:41 +0200

Thanks, it solved the problem at hand.
But as you quite correctly assumed the next step I have to do is to identify all diagnose combinations that are there.
Suggestions?

Taavi

David Kantor wrote:


To Taavi Lai:

There are several way of doing this. Here's one.

Say you have a variable called diag for diagnosis, and suppose that you are looking for persons that have the combination of values 2,3 & 7. (Those may not be realistic diag values, but they will suffice for now.) Also suppose that you have personid to identify persons.

sort personid
egen byte hasdiag2 = max(diag==2), by(personid)
egen byte hasdiag3 = max(diag==3), by(personid)
egen byte hasdiag7 = max(diag==7), by(personid)

/* (And you could compact that sequence with a -foreach- if you prefer.) */

gen byte hascombination = hasdiag2 & hasdiag3 & hasdiag7

/* You could also ...
bysort personid: keep if _n==1
-- if you want to reduce to one observation per person.
(And it could go before the -gen byte hascombination-.)

*/

----
This detects that the person has at least the particular combination; it does not detect whether these are the ONLY diagnoses. You were not clear whether that was part of the problem. If it is, then
more needs to be done.

I hope this is helpful.
-- David


At 11:42 PM 2/4/2005 +0200, Taavi Lai wrote:


Could someone point me a way:
I have a list of people and their diagnoses. One person can have varying number of observations according to the number of diagnoses.
I need to identify people with specific combination of diagnoses.

Taavi Lai

David Kantor
Institute for Policy Studies
Johns Hopkins University
dkantor@jhu.edu
410-516-5404
*
*   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/

--
Tervishoiu instituut
Tartu Ülikool
Ravila 19
Tartu 50411

GSM: 56663859
Fax: 7374192
e-mail: taavi.lai@ut.ee

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index