LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (December 2006)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 7 Dec 2006 14:24:14 -0600
Reply-To:     "Marks, Jim" <Jim.Marks@lodgenet.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         "Marks, Jim" <Jim.Marks@lodgenet.com>
Subject:      Re: DO IF and LEAD function
Content-Type: text/plain; charset="utf-8"

You need to sort the data by ID and date descending and use the LAG function:

** not tested.

SORT CASES by ID datevar (D).

STRING LeadDx (A5).

DO IF (ID = LAG(ID,1)). COMPUTE LeadDx = LAG(PrinDx,1). END IF.

String variables do not have a system missing value-- they are filled with blanks. You can use a string to stand for missing or autorecode to create numbers in place of strings.

HTH

--jim

-----Original Message----- From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of C Kirkman Sent: Thursday, December 07, 2006 2:07 PM To: SPSSX-L@LISTSERV.UGA.EDU Subject: DO IF and LEAD function

I have patient level data. Each patient has one or more cases, with each case an episode of care. For those patients that have more than one episode of care, for each case I want to create a “Readmission diagnosis” variable based on the diagnosis of the subsequent episode of care. (Data is sorted by patient ID then by order of episodes of care.) I am trying to do this using the LEAD function to 1) create a value in the new variable for only those patients that have more than one episode of care; and 2) create the value in the new variable based on the diagnosis for the subsequent episode of care.

This is the syntax I have so far:

STRING LeadDx (A5).

DO IF (ID = LEAD(ID,1)). COMPUTE LeadDx = LEAD(PrinDx,1). END IF.

I’m getting this error message: DO IF (ID = LEAD(ID,1)).

>Error # 4023 in column 24. Text: LEAD >An expression contains a string of characters followed by a left >parenthesis, indicating that the string of characters is a function or >vector name, but the characters do not match any existing function or >vector. Check the spelling. >This command not executed.

Suggestions? Also, is there any way to initialize the string var "LeadDx" to the system missing value?


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