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: Re: How to search in a large database the id of patients whos medication is revised
From
"Lachenbruch, Peter" <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
st: RE: Re: How to search in a large database the id of patients whos medication is revised
Date
Wed, 12 May 2010 08:42:20 -0700
I had a similar idea, but was thinking that one should sort on patient id AND visit number. It is likely that at some point, Muhammad will want to identify when the prescription changes. I might do a preserve followed by sort patient id visit and then list patient id and visit for those whose prescriptions aren't the same at two consecutive visits.
Tony
Peter A. Lachenbruch
Department of Public Health
Oregon State University
Corvallis, OR 97330
Phone: 541-737-3832
FAX: 541-737-4001
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Joseph Coveney
Sent: Wednesday, May 12, 2010 7:52 AM
To: [email protected]
Subject: st: Re: How to search in a large database the id of patients whos medication is revised
Muhammad Riaz wrote:
I would be grateful if somebody could give me a syntax for a command to look
at the id whether any patients have received a the same or different
prescription.
A patient gets prescription for medication, the medication could be one of
(say A, B, C) for the same disease. the patients prescription might be revised
may be with old medication or any other out of the three (A, B, C) at another
date. Just to make it clear that the prescription is not revised for all
patients but revised for some of them. I want to search the ids of patients
whose prescription is revised and to see whether it is revised with the same
medication or any other out of three (A, B, C). the database look like as below
for example medication (A) is revised for id=100002120 at date 23-Dec-09 and
28-Feb-10. I need run pick up these repeated ids and see there medication
whether it is the same or different.
--------------------------------------------------------------------------------
Your database didn't show up in your post, but I'm guessing that you're looking
for something along the lines of
bysort patient_id (prescription_date): generate byte ///
medication_change = medication_code != medication_code[_n - 1] if _n > 1
or something analogous that will flag prescription changes within each patient.
You can then home-in on the cases of interest among flagged patients with
something like
replace medication_change = 0 if !inlist(medication_code, "A", "B", "C")
by patient_id: egen byte interesting_case = max(medication_change)
keep if interesting_case // Be sure not to overwrite your dataset after this!
list patient_id medication_code, noobs sepby(patient_id) abbreviate(15)
Joseph Coveney
*
* 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/