Creating a New CaseID

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

Creating a New CaseID

DKUKEC
*Dear Listers,

I am trying to apply a new definition of case. The data were provided in a manner where a unqiue CASE_ID equals one Case.  However,
I would like a case to include specific types of court orders - represented by VAR CODESCX, where (CODESCX=1) is the start of a case.
Therefore, when the first order of a CASE_ID is 1, the following SYNTAX works; however, in some cases, a new
case may start with another CODESCX value besides 1.  In this situtation, the RPUID has a new CASE_ID number and the first CODESX
has a value other than a 1.  My question is, how do I start a NEW Case ID in this circumstance.

As always, your assistance is greatly appreciated.  I have included a sample dataset and syntax for your information.

Cheers,
Damir

DATA LIST FREE / RPUID (F4) CASE_ID (A17) CASE_FILE_DATEX (DATE11) COURT_ORDER_DATEX (DATE11) CODESCX (F3).
BEGIN DATA.
6294 2005MHXXXX1 18-Apr-2005 18-Apr-2005 1.00
6294 2005MHXXXX1 18-Apr-2005 11-May-2005 2.00
6294 2005MHXXXX2 27-May-2005 27-May-2005 3.00
6294 2005MHXXXX2 27-May-2005 01-Jun-2005 4.00
6294 2005MHXXXX2 27-May-2005 14-Jul-2005 4.00
6294 2005MHXXXX2 27-May-2005 27-Sep-2005 6.00
6294 2005MHXXXX2 27-May-2005 27-Sep-2005 6.00
6294 2005MHXXXX2 27-May-2005 05-Dec-2005 2.00
6294 2005MHXXXX2 27-May-2005 11-Jan-2006 6.00
6294 2005MHXXXX2 27-May-2005 11-Jan-2006 6.00
6294 2005MHXXXX2 27-May-2005 07-Mar-2006 6.00
6294 2005MHXXXX2 27-May-2005 20-Mar-2006 2.00
6294 2005MHXXXX2 27-May-2005 25-Apr-2006 2.00
6294 2005MHXXXX2 27-May-2005 19-Jul-2006 6.00
6294 2006MHXXXX3 12-Oct-2006 12-Oct-2006 1.00
6294 2006MHXXXX3 12-Oct-2006 28-Oct-2006 2.00
6294 2006MHXXXX4 28-Oct-2006 28-Oct-2006 3.00
6294 2006MHXXXX4 28-Oct-2006 02-Dec-2006 6.00
6294 2006MHXXXX5 29-Dec-2006 29-Dec-2006 1.00
6294 2006MHXXXX5 29-Dec-2006 04-Jan-2007 2.00
6294 2007MHXXXX6 31-Jan-2007 31-Jan-2007 3.00
6294 2007MHXXXX6 31-Jan-2007 09-Feb-2007 4.00
6294 2010MHXXXX8 31-Jan-2010 09-Feb-2010 6.00
1234 2012MHXXXX9 31-Jan-2012 09-Feb-2012 1.00
END DATA.
DATASET NAME EXAMPLE.

SORT CASES BY RPUID (A) COURT_ORDER_DATEX (A) CODESCX (A).
DO IF CODESCX=1.
   COMPUTE CASEIDNX=$CASENUM.
END IF.
EXECUTE.
IF MISSING (CASEIDNX) CASEIDNX = lag (CASEIDNX).
VARIABLE LABELS CASEIDNX 'Unique CASES X ID (SPSS)'.
EXECUTE.

SORT CASES BY RPUID CASE_ID COURT_ORDER_DATEX (A).
LIST  RPUID CASE_ID CASE_FILE_DATEX COURT_ORDER_DATEX CODESCX CASEIDNX.
EXECUTE.
Reply | Threaded
Open this post in threaded view
|

Re: Creating a New CaseID

David Marso
Administrator
SORT CASES BY RPUID (A) COURT_ORDER_DATEX (A) CODESCX (A).
MATCH FILES / FILE * / BY RPUID COURT_ORDER_DATEX / FIRST=@TOP@.
DO IF @TOP@ .

+   COMPUTE CASEIDNX=$CASENUM.
ELSE .
+   COMPUTE CASEIDNX = lag (CASEIDNX).
END IF.
EXECUTE.
VARIABLE LABELS CASEIDNX 'Unique CASES X ID (SPSS)'.
......
DKUKEC wrote
*Dear Listers,

I am trying to apply a new definition of case. The data were provided in a manner where a unqiue CASE_ID equals one Case.  However,
I would like a case to include specific types of court orders - represented by VAR CODESCX, where (CODESCX=1) is the start of a case.
Therefore, when the first order of a CASE_ID is 1, the following SYNTAX works; however, in some cases, a new
case may start with another CODESCX value besides 1.  In this situtation, the RPUID has a new CASE_ID number and the first CODESX
has a value other than a 1.  My question is, how do I start a NEW Case ID in this circumstance.

As always, your assistance is greatly appreciated.  I have included a sample dataset and syntax for your information.

Cheers,
Damir

DATA LIST FREE / RPUID (F4) CASE_ID (A17) CASE_FILE_DATEX (DATE11) COURT_ORDER_DATEX (DATE11) CODESCX (F3).
BEGIN DATA.
6294 2005MHXXXX1 18-Apr-2005 18-Apr-2005 1.00
6294 2005MHXXXX1 18-Apr-2005 11-May-2005 2.00
6294 2005MHXXXX2 27-May-2005 27-May-2005 3.00
6294 2005MHXXXX2 27-May-2005 01-Jun-2005 4.00
6294 2005MHXXXX2 27-May-2005 14-Jul-2005 4.00
6294 2005MHXXXX2 27-May-2005 27-Sep-2005 6.00
6294 2005MHXXXX2 27-May-2005 27-Sep-2005 6.00
6294 2005MHXXXX2 27-May-2005 05-Dec-2005 2.00
6294 2005MHXXXX2 27-May-2005 11-Jan-2006 6.00
6294 2005MHXXXX2 27-May-2005 11-Jan-2006 6.00
6294 2005MHXXXX2 27-May-2005 07-Mar-2006 6.00
6294 2005MHXXXX2 27-May-2005 20-Mar-2006 2.00
6294 2005MHXXXX2 27-May-2005 25-Apr-2006 2.00
6294 2005MHXXXX2 27-May-2005 19-Jul-2006 6.00
6294 2006MHXXXX3 12-Oct-2006 12-Oct-2006 1.00
6294 2006MHXXXX3 12-Oct-2006 28-Oct-2006 2.00
6294 2006MHXXXX4 28-Oct-2006 28-Oct-2006 3.00
6294 2006MHXXXX4 28-Oct-2006 02-Dec-2006 6.00
6294 2006MHXXXX5 29-Dec-2006 29-Dec-2006 1.00
6294 2006MHXXXX5 29-Dec-2006 04-Jan-2007 2.00
6294 2007MHXXXX6 31-Jan-2007 31-Jan-2007 3.00
6294 2007MHXXXX6 31-Jan-2007 09-Feb-2007 4.00
6294 2010MHXXXX8 31-Jan-2010 09-Feb-2010 6.00
1234 2012MHXXXX9 31-Jan-2012 09-Feb-2012 1.00
END DATA.
DATASET NAME EXAMPLE.

SORT CASES BY RPUID (A) COURT_ORDER_DATEX (A) CODESCX (A).
DO IF CODESCX=1.
   COMPUTE CASEIDNX=$CASENUM.
END IF.
EXECUTE.
IF MISSING (CASEIDNX) CASEIDNX = lag (CASEIDNX).
VARIABLE LABELS CASEIDNX 'Unique CASES X ID (SPSS)'.
EXECUTE.

SORT CASES BY RPUID CASE_ID COURT_ORDER_DATEX (A).
LIST  RPUID CASE_ID CASE_FILE_DATEX COURT_ORDER_DATEX CODESCX CASEIDNX.
EXECUTE.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Creating a New CaseID

DKUKEC
Thank you David,

I have slightly revised your syntax - which as always is more to the point - compared to my long round-about syntax!  However, I am still encountering the same delimma.

When the "new case" begins with CODESCX value other than a 1, the $casenum assigns the same number to the following CASE_ID, although, in this case the CASE_ID indicates its a new case.  From the output (using the syntax below): I am trying to create CASEIDNX with the following values for the specific row numbers (RPUID and CASE_ID).

Thanks,
Damir

David's proposed syntax with my minor revision:

SORT CASES BY RPUID (A) COURT_ORDER_DATEX (A) CODESCX (A).
MATCH FILES / FILE * / BY RPUID CASE_ID / FIRST=@TOP@.
DO IF @TOP@ .
+   COMPUTE CASEIDNX=$CASENUM.
ELSE .
+   COMPUTE CASEIDNX = lag (CASEIDNX).
END IF.
EXECUTE.
VARIABLE LABELS CASEIDNX 'Unique CASES X ID (SPSS)'.



RPUID CASE_ID           CASE_FILE_DATEX COURT_ORDER_DATEX CODESCX CASEIDNX
 
 1234 2012MHXXXX9         31-JAN-2012      09-FEB-2012        1      1.00
 6294 2005MHXXXX1         18-APR-2005      18-APR-2005        1      2.00
 6294 2005MHXXXX1         18-APR-2005      11-MAY-2005        2      2.00
 6294 2005MHXXXX2         27-MAY-2005      27-MAY-2005        3      2.00
 6294 2005MHXXXX2         27-MAY-2005      01-JUN-2005        4      2.00
 6294 2005MHXXXX2         27-MAY-2005      14-JUL-2005        4      2.00
 6294 2005MHXXXX2         27-MAY-2005      27-SEP-2005        6      2.00
 6294 2005MHXXXX2         27-MAY-2005      27-SEP-2005        6      2.00
 6294 2005MHXXXX2         27-MAY-2005      05-DEC-2005        2      2.00
 6294 2005MHXXXX2         27-MAY-2005      11-JAN-2006        6      2.00
 6294 2005MHXXXX2         27-MAY-2005      11-JAN-2006        6      2.00
 6294 2005MHXXXX2         27-MAY-2005      07-MAR-2006        6      2.00
 6294 2005MHXXXX2         27-MAY-2005      20-MAR-2006        2      2.00
 6294 2005MHXXXX2         27-MAY-2005      25-APR-2006        2      2.00
 6294 2005MHXXXX2         27-MAY-2005      19-JUL-2006        6      2.00
 6294 2006MHXXXX3         12-OCT-2006      12-OCT-2006        1      3.00
 6294 2006MHXXXX3         12-OCT-2006      28-OCT-2006        2      3.00
 6294 2006MHXXXX4         28-OCT-2006      28-OCT-2006        3      3.00
 6294 2006MHXXXX4         28-OCT-2006      02-DEC-2006        6      3.00
 6294 2006MHXXXX5         29-DEC-2006      29-DEC-2006        1      4.00
 6294 2006MHXXXX5         29-DEC-2006      04-JAN-2007        2      4.00
 6294 2007MHXXXX6         31-JAN-2007      31-JAN-2007        3      4.00
 6294 2007MHXXXX6         31-JAN-2007      09-FEB-2007        4      4.00
 6294 2010MHXXXX8         31-JAN-2010      09-FEB-2010        6      5.00



Reply | Threaded
Open this post in threaded view
|

Re: Creating a New CaseID

DKUKEC
Dear Listers,

Sorry, but upon further review of my post and explanation, I noticed that I should further clarify the following.  The new definition of case can inlude a maximum of two unique CASE_IDs; therefore, I am looking to identify all those cases where subsequent CASE_ID (third) starts with a CODESCX that does NOT equal 1.

Sorry about the confusion my description may have caused.

Damir