|
At 02:37 PM 5/5/2011, Krinsky, Alan wrote:
>Patients can have multiple visits and multiple prescriptions. For
>now, let's say each patient-office visit is its own case, but each
>patient has multiple prescriptions. I have one file of unique
>patient-office visit combinations. And, I have each unique
>patient-prescription date in a separate file
So: you have one file with one case per office visit, one file with
one record per prescription, yes?
>For example, I need to figure out if a pharmacy prescription is
>close to the date of a particular office visit.
It depends on what "close to" means. If you mean what prescriptions
are near the office visit BUT AFTER IT, and before any later office
visit -- that is, you're trying to find what office visit was the
stimulus for writing each prescription -- it can be done with an ADD
FILE in which visits and prescriptions are interleaved by patient and
date, and you use LAG to carry over to each prescription the date of
the last preceding office visit.
If, say, you want to find the closest office visit in either time
direction for every prescription, you have a true many-to-many merge.
That is now a solved problem (see "Many-to-many merge in SPSS", Thu,
26 Nov 2009); you can get a file of all pairs of office visits and
prescriptions, and select from those the cases where the prescription
is close to the date of the visit, by your criteria.
>To find out how many prescriptions per patient, I can do cases to
>variables, or run an AGGREGATE command and get a count that way,
>without restructuring.
Much the easier, I think.
>I then need to compare the office visit date with each prescription date.
Given that the solution you're describing is clumsy, and that there's
no clear simplification of the selection logic, I suggest the
many-to-many merge. That bypasses concern about maximum number of
prescriptions per patient, etc; and since there'll be only one office
visit and one prescription in each record, the selection logic is
much simplified.
Let us know how it works out; especially, if there are any questions
about the algorithm.
-Best wishes,
Richard Ristow
=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
|