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: Re: How to search in a large database the id of patients whos medication is revised


From   "Joseph Coveney" <jcoveney@bigplanet.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: How to search in a large database the id of patients whos medication is revised
Date   Wed, 12 May 2010 23:51:58 +0900

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/


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