LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (December 2008)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 6 Dec 2008 11:01:12 -0500
Reply-To:     Richard Ristow <wrristow@mindspring.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Richard Ristow <wrristow@mindspring.com>
Subject:      Re: Patient stays revisited
Comments: To: Clive Downs <clive.downs@READING.GOV.UK>
Comments: cc: Gene Maguin <emaguin@buffalo.edu>
In-Reply-To:  <200812041003.mB3Jm9nL029695@malibu.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"; format=flowed

At 05:03 AM 12/4/2008, Clive Downs wrote:

>I want to match a dataset of patients in hospital for specified >periods (data set 1): |-----------------------------|---------------------------| |Output Created |06-DEC-2008 10:33:07 | |-----------------------------|---------------------------| [D1.CarePeriod] id POCs POCend

01 04-JAN-2004 05-MAY-2005 01 05-FEB-2006 . 02 04-JUL-2003 06-DEC-2003

Number of cases read: 3 Number of cases listed: 3

>with a dataset of patients and review dates (data set 2): |-----------------------------|---------------------------| |Output Created |06-DEC-2008 10:33:24 | |-----------------------------|---------------------------| [D2.ReviewDate] id revdate

01 05-FEB-2004 01 12-MAR-2004 01 04-MAR-2006 01 05-JUL-2006 02 05-AUG-2003 02 06-SEP-2003 02 08-NOV-2003

Number of cases read: 7 Number of cases listed: 7

>so that each review date for the patient is linked to the relevant >hospital period (via id and review date). The end product should look like, > >id POCs POCend revdate >01 04-JAN-2004 05-MAY-2005 05-FEB-2004 >01 04-JAN-2004 05-MAY-2005 12-MARCH-2004 >01 05-FEB-2006 (SYSMIS) 04-MAR-2006 >01 05-FEB-2006 (SYSMIS) 01 5-JUL-2006 >02 04-JUL-2003 06-DEC-200302 05-AUG-2003 >02 04-JUL-2003 06-DEC-200302 06-SEP-2003 >02 04-JUL-2003 06-DEC-200302 08-NOV-2003

As has been proposed, this can be solved using CASESTOVARS & VECTOR logic; or, when the data is in a SQL database, by SQL joins. But there's also a natural solution with SPSS sequential logic. The following is tested, with thanks for excellent test data:

* For merging: define the 'review date' for care periods as . * the beginning of the period: . ADD FILES /FILE=D1.CarePeriod.

NUMERIC revdate(DATE11). COMPUTE revdate=POCs.

* Interleave the files, with period-of-care records preceding . * review-date records when dates are tied: . ADD FILES /FILE=* /IN=PeriodRec /FILE=D2.ReviewDate /BY id revdate /KEEP=id POCs POCend revdate ALL.

* Carry over period-of-care dates to review-date records, and . * drop period-of-care records: .

DO IF NOT PeriodRec. . COMPUTE POCs = LAG(POCs). . COMPUTE POCend = LAG(POCend). END IF.

SELECT IF NOT PeriodRec. LIST. |-----------------------------|---------------------------| |Output Created |06-DEC-2008 10:52:54 | |-----------------------------|---------------------------| id POCs POCend revdate PeriodRec

01 04-JAN-2004 05-MAY-2005 05-FEB-2004 0 01 04-JAN-2004 05-MAY-2005 12-MAR-2004 0 01 05-FEB-2006 . 04-MAR-2006 0 01 05-FEB-2006 . 05-JUL-2006 0 02 04-JUL-2003 06-DEC-2003 05-AUG-2003 0 02 04-JUL-2003 06-DEC-2003 06-SEP-2003 0 02 04-JUL-2003 06-DEC-2003 08-NOV-2003 0

Number of cases read: 7 Number of cases listed: 7 ===================================== APPENDIX: Test data, and code Contains LIST statements that are not included in the posted output. (WRR: not saved separately) ===================================== * DATA SET 1 - Periods of care . * NB 2nd record has a null end date to show the period of care . * has not yet terminated. .

DATA LIST FREE/ id(A2) POCs(DATE11) POCend(DATE11). BEGIN DATA 01 04-JAN-2004 05-MAY-2005 01 05-FEB-2006 . 02 04-JUL-2003 06-DEC-2003 END DATA. DATASET NAME D1.CarePeriod WINDOW=FRONT.

* DATA SET 2 - Review dates .

DATA LIST FREE/ id(A2) revdate(DATE11). BEGIN DATA 01 05-FEB-2004 01 12-MARCH-2004 01 04-MAR-2006 01 5-JUL-2006 02 05-AUG-2003 02 06-SEP-2003 02 08-NOV-2003 END DATA.

DATASET NAME D2.ReviewDate WINDOW=FRONT.

* ..... Post after this point ........ .

DATASET ACTIVATE D1.CarePeriod WINDOW=FRONT. LIST.

DATASET ACTIVATE D2.ReviewDate WINDOW=FRONT. LIST.

NEW FILE. * For merging: define the 'review date' for care periods as . * the beginning of the period: .

ADD FILES /FILE=D1.CarePeriod.

NUMERIC revdate(DATE11). COMPUTE revdate=POCs.

* Interleave the files, with period-of-care records preceding . * review-date records when dates are tied: .

ADD FILES /FILE=* /IN=PeriodRec /FILE=D2.ReviewDate /BY id revdate /KEEP=id POCs POCend revdate ALL.

. /**/ LIST /*-*/.

* Carry over period-of-care dates to review-date records, and . * drop period-of-care records: .

DO IF NOT PeriodRec. . COMPUTE POCs = LAG(POCs). . COMPUTE POCend = LAG(POCend). END IF.

. /**/ LIST /*-*/.

SELECT IF NOT PeriodRec. LIST.

===================== 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


Back to: Top of message | Previous page | Main SPSSX-L page