DO IF and LEAD function

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

DO IF and LEAD function

C Kirkman
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?
Reply | Threaded
Open this post in threaded view
|

Re: DO IF and LEAD function

Marks, Jim
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:[hidden email]] On Behalf Of C Kirkman
Sent: Thursday, December 07, 2006 2:07 PM
To: [hidden email]
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?
Reply | Threaded
Open this post in threaded view
|

Re: DO IF and LEAD function

C Kirkman
In reply to this post by C Kirkman
OK, that worked. But I'm curious. Does anyone know why the LEAD function
doesn't work in the same way as LAG?
Reply | Threaded
Open this post in threaded view
|

Re: DO IF and LEAD function

Beadle, ViAnn
There is no LEAD function used in transformations. There is a special LEAD function used within the CREATE command but the syntax is different.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of C Kirkman
Sent: Friday, December 08, 2006 12:18 PM
To: [hidden email]
Subject: Re: DO IF and LEAD function

OK, that worked. But I'm curious. Does anyone know why the LEAD function
doesn't work in the same way as LAG?
Reply | Threaded
Open this post in threaded view
|

Paste multiple columns from Excel into SPSS

Gary Oliver
Colleagues

Using the paste command I would like to paste several columns copied as
a block from Excel into SPSS. However I am finding that SPSS will only
paste the first column of the block. Am I encountering an SPSS
limitation? If so, is there a work-around?

Warm regards/gary


Unit Co-ordinator for Business Information Systems
(A Postgraduate Master of Commerce and Master of Business unit)
School of Business
The University of Sydney
------------------------
      ,-_|\       Building H69, Office 437
     /     \      Corner Codrington Street
     \_,-._*      & Rose Street
                  Darlington 2006
           @      Australia
--------------------------------------
E-mail: [hidden email]
------------------------
Location details:
Travelling from Broadway, turn south off City Road
Navigate toward the Acquatic Centre
------------------------
University Map: http://db.auth.usyd.edu.au/directories/map/index.stm
University Website:
www.usyd.edu.au
Faculty Website
www.econ.usyd.edu.au
------------------------
Faculty Student Information Office
(Timetables, Special Consideration)
Merewether Building
Enter from City Road side
e-mail: [hidden email]
Phone: 9351-3076
----------------------------------
Executive Officer for Business Information Systems
Katy Roy
Room 347, Building H69
E-mail: [hidden email]
Phone: 9036 9432
---------------------------------


>>-----Original Message-----
>>From: SPSSX(r) Discussion [mailto:[hidden email]]
>>On Behalf Of Beadle, ViAnn
>>Sent: Saturday, December 09, 2006 6:37 AM
>>To: [hidden email]
>>Subject: Re: DO IF and LEAD function
>>
>>There is no LEAD function used in transformations. There is a
>>special LEAD function used within the CREATE command but the
>>syntax is different.
>>
>>-----Original Message-----
>>From: SPSSX(r) Discussion [mailto:[hidden email]]
>>On Behalf Of C Kirkman
>>Sent: Friday, December 08, 2006 12:18 PM
>>To: [hidden email]
>>Subject: Re: DO IF and LEAD function
>>
>>OK, that worked. But I'm curious. Does anyone know why the
>>LEAD function doesn't work in the same way as LAG?
>>
Reply | Threaded
Open this post in threaded view
|

Re: Paste multiple columns from Excel into SPSS

Daniel Robertson
The only problem I've encountered doing this is when one of the Excel
columns is non-numeric, as the default variable type is F8.2. If you
have Excel columns with strings, define the SPSS variable type first
before pasting to let SPSS know to expect non-numeric values. Of course,
if you data are such that you can import the Excel file you can avoid this.

Dan R.

Gary Oliver wrote:

> Colleagues
>
> Using the paste command I would like to paste several columns copied as
> a block from Excel into SPSS. However I am finding that SPSS will only
> paste the first column of the block. Am I encountering an SPSS
> limitation? If so, is there a work-around?
>
> Warm regards/gary
>
>
> Unit Co-ordinator for Business Information Systems
> (A Postgraduate Master of Commerce and Master of Business unit)
> School of Business
> The University of Sydney
> ------------------------
>       ,-_|\       Building H69, Office 437
>      /     \      Corner Codrington Street
>      \_,-._*      & Rose Street
>                   Darlington 2006
>            @      Australia
> --------------------------------------
> E-mail: [hidden email]
> ------------------------
> Location details:
> Travelling from Broadway, turn south off City Road
> Navigate toward the Acquatic Centre
> ------------------------
> University Map: http://db.auth.usyd.edu.au/directories/map/index.stm
> University Website:
> www.usyd.edu.au
> Faculty Website
> www.econ.usyd.edu.au
> ------------------------
> Faculty Student Information Office
> (Timetables, Special Consideration)
> Merewether Building
> Enter from City Road side
> e-mail: [hidden email]
> Phone: 9351-3076
> ----------------------------------
> Executive Officer for Business Information Systems
> Katy Roy
> Room 347, Building H69
> E-mail: [hidden email]
> Phone: 9036 9432
> ---------------------------------
>
>
>
>>> -----Original Message-----
>>> From: SPSSX(r) Discussion [mailto:[hidden email]]
>>> On Behalf Of Beadle, ViAnn
>>> Sent: Saturday, December 09, 2006 6:37 AM
>>> To: [hidden email]
>>> Subject: Re: DO IF and LEAD function
>>>
>>> There is no LEAD function used in transformations. There is a
>>> special LEAD function used within the CREATE command but the
>>> syntax is different.
>>>
>>> -----Original Message-----
>>> From: SPSSX(r) Discussion [mailto:[hidden email]]
>>> On Behalf Of C Kirkman
>>> Sent: Friday, December 08, 2006 12:18 PM
>>> To: [hidden email]
>>> Subject: Re: DO IF and LEAD function
>>>
>>> OK, that worked. But I'm curious. Does anyone know why the
>>> LEAD function doesn't work in the same way as LAG?
>>>
>>>
>
>


--
Daniel Robertson
Senior Research and Planning Associate
Institutional Research and Planning
Cornell University, Ithaca NY, 14853-2801
[hidden email] / ph:607.255.9642