Hi,
I am working with two datasets, the first dataset includes date and
time for a drug administration for a patient and the second includes
date and time for which care units the patient have been visit the
same date for the drug administration.
In some cases, the patient have visit two or more care units the same
day and then the drug administration is matched/connected to two or
more care units. I now want to ?match? (eg. drop care units) the drug
administration with the care unit closest in time for the drug
administration.
Are there any command in STATA like ?keep if time is closest to another time?
Example (the drug administration is now connected to two care units)
Id drug. adm.date drug. adm.time care.unit.date careunit.time
careunit
1 2mar06 11.15 2mar06 10.01 Cardio
1 2mar06 11.15 2mar06 11.25
Inf.dis
I now want to keep the second row, the one that the time for drug.adm
is closest in time to the care unit time.
I hope anyone can help be!
/Thomas
*
* 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/