|
I am currently using a corrections (charge) dataset with unique Inmate IDs,
unique Admission IDs, and Admission Dates. I am hoping someone would suggest some syntax that would calculate the duration(in days) between an individualâs latest admission date with the most recent admission date. For example, ID 5722 has four records, with three unique admissions. I would like to calculate the duration in days between Admission ID 28 and 29, and then Admission ID 29 and 33 for ID. ID ADID Admission Date 3145 6.00 26-Jan-2005 15:32:17.00 3145 7.00 28-Jan-2005 12:19:32.00 5137 19.00 4-Aug-2005 21:41:52.00 5137 20.00 24-Jun-2006 23:51:35.00 5137 20.00 24-Jun-2006 23:51:35.00 5137 20.00 24-Jun-2006 23:51:35.00 5137 20.00 24-Jun-2006 23:51:35.00 5137 24.00 24-Sep-2008 20:28:56.00 5137 24.00 24-Sep-2008 20:28:56.00 5722 28.00 4-Feb-2005 04:32:43.00 5722 29.00 9-Aug-2008 17:28:01.00 5722 33.00 10-Sep-2009 17:28:01.00 5722 33.00 10-Sep-2009 17:28:01.00 7509 72.00 31-Aug-2005 02:44:47.00 7509 73.00 7-Sep-2005 16:50:20.00 7509 73.00 7-Sep-2005 16:50:20.00 ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (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 |
|
Hi Damir,
I was having a little trouble reading the date data the way you posted it, but, assuming that your admission date is a date format, the syntax below will work just the same.
Thanks,
Ari
***************************************************.
DATA LIST LIST /ID (F8.0) ADID (F8.2) AdmissionDate (DATE11). BEGIN DATA 3145 6.00 26-Jan-2005 3145 7.00 28-Jan-2005 5137 19.00 4-Aug-2005 5137 20.00 24-Jun-2006 5137 20.00 24-Jun-2006 5137 20.00 24-Jun-2006 5137 20.00 24-Jun-2006 5137 24.00 24-Sep-2008 5137 24.00 24-Sep-2008 5722 28.00 4-Feb-2005 5722 29.00 9-Aug-2008 5722 33.00 10-Sep-2009 5722 33.00 10-Sep-2009 7509 72.00 31-Aug-2005 7509 73.00 7-Sep-2005 7509 73.00 7-Sep-2005 END DATA. COMPUTE DaysSinceLastAdmission=0.
EXE. IF (LAG(ID,1))=ID DaysSinceLastAdmission=(AdmissionDate -(Lag(AdmissionDate,1)))/86400.
EXE. On Mon, Apr 27, 2009 at 4:09 PM, Damir <[hidden email]> wrote: I am currently using a corrections (charge) dataset with unique Inmate IDs, |
| Free forum by Nabble | Edit this page |
