|
Hello there:
I really do need some help. I need to determine what the youths risk score was at entry and at exit.
Our youth are given a risk assessment once a month while in our custody. This is what the risk file looks like:
K# RiskDate RiskLevel FinalScore
025319 9-Feb-2010 08:16:53 High 63.27
025319 12-Dec-2009 23:06:11 Low 38.47 025319 28-Aug-2009 21:26:02 Low 42.97 025319 29-Jul-2009 07:37:00 Low 47.77 025319 30-Apr-2009 18:38:28 Low 41.87 025319 6-Apr-2009 22:06:10 Low 42.57 025319 17-Dec-2008 17:04:35 Low 35.47 025319 16-Sep-2008 16:16:38 Low 44.97 025319 16-Jun-2008 13:32:32 Medium 51.73 025319 24-Mar-2008 13:33:40 Medium 51.73 025319 24-Feb-2008 18:04:11 Medium 51.73 025319 28-Nov-2007 10:12:13 Low 38.6 025319 23-Feb-2006 16:59:33 Medium 53.07 025320 2-Jan-2009 10:10:02 Medium 53.07 025320 12-Oct-2008 00:07:12 Medium 53.07 025320 14-Jul-2008 21:53:34 High 65.03 025320 13-Apr-2008 17:36:18 High 66.49 This is the file I'm interest in matching up.
K# ParoleIN ParoleOUT Status cohort SecureIn SecureOut Status1
025319 14-Jan-2010 14:31:00 16-Feb-2010 06:17:00 7 3 28-Aug-2009 11:43:00 14-Jan-2010 14:31:00 2
025319 9-Apr-2009 11:35:00 14-Aug-2009 13:20:00 7 2 24-Dec-2008 15:54:00 9-Apr-2009 11:35:00 2 025319 4-Dec-2008 16:20:00 10-Dec-2008 09:06:00 7 1 18-Sep-2008 08:34:00 4-Dec-2008 16:20:00 2 025320 12-Dec-2008 08:20:00 29-Jan-2009 08:28:00 7 1 20-Dec-2007 16:08:00 12-Dec-2008 08:20:00 2 So for instance, Youth #25319 came in three time. The first time was Sept 18, 2008 so I would need the Sept 16th Low 44.97 record. Then he exited on Dec 4,2008 so I would like to match it up
with Dec 17th Low 35.47 record...then I would need to go to the next one.
I hope this all makes senses. I'm really lost...any assistance would be nice.
Thanks.
Stella Vasquez, Planner
Research & Development
1624 W Adams
Phoenix, AZ 85007
(602) 542-2272 work
**The information contained in this communication is privileged and confidential and is intended solely for the individual[s] and/or entities named herein. This information is not to be disseminated. If you have received this message in error, please reply to the sender and notify the sender of the error and then permanently delete the message and sent item. Thank you.** |
|
Stella,
Here is the general procedure I would suggest. There may well be more.elegant approaches. First I would arrange the risk data so there is one record per case using CASESTOVARS. Let's call thie new dataset the Risk Table. second, sort the parole data and the risk table by subject ID then so a one to many merge so that each record in the parole file for a particular ID is matched to the corresponding iD in the risk table. Do this by using MATCH FILES FILE = parole file / TABLE = risk table / BY ID. . The resulting file has all the risk scores matched to each record inb the parole file. What we need to do next is , to select the one that is relevant. From your example, I assume that you want the risk score that is closest in time to the OUT date (for RISK OUT) even if the risk assessment is made slightly after the OUT date. To identify the risk score that is closest in time. Compute the number of days between the OUT date and each risk score, then compute the absolute value of this difference. Each risk assessment will have a corresponding index of temporal closeness (let's call this an index score). If the nth index score is the lowest index score, then the nth risk score is the one you want. Compute Risk Out = nth risk score. For example. If the 2nd index score is the lowest, then Risk Out = 2nd risk score. This may sound complicated but it can be accomplished with a series of IF statements. Similarly., to compute Risk In, use the same procedure to find the risk assessment that is closest in time, and compute Risk In to equal that risk score. Sorry if this is a bit brief - please let me know if you have ny questions or if any sections need elabration (which I am sure they do). Good Luck! Steve Brand www.StatisticsDoc.com From: Stella Vasquez <[hidden email]>
Date: Thu, 13 May 2010 13:25:57 -0700 To: <[hidden email]> Subject: Multiple data Hello there:
I really do need some help. I need to determine what the youths risk score was at entry and at exit.
Our youth are given a risk assessment once a month while in our custody. This is what the risk file looks like:
K# RiskDate RiskLevel FinalScore
025319 9-Feb-2010 08:16:53 High 63.27
025319 12-Dec-2009 23:06:11 Low 38.47 025319 28-Aug-2009 21:26:02 Low 42.97 025319 29-Jul-2009 07:37:00 Low 47.77 025319 30-Apr-2009 18:38:28 Low 41.87 025319 6-Apr-2009 22:06:10 Low 42.57 025319 17-Dec-2008 17:04:35 Low 35.47 025319 16-Sep-2008 16:16:38 Low 44.97 025319 16-Jun-2008 13:32:32 Medium 51.73 025319 24-Mar-2008 13:33:40 Medium 51.73 025319 24-Feb-2008 18:04:11 Medium 51.73 025319 28-Nov-2007 10:12:13 Low 38.6 025319 23-Feb-2006 16:59:33 Medium 53.07 025320 2-Jan-2009 10:10:02 Medium 53.07 025320 12-Oct-2008 00:07:12 Medium 53.07 025320 14-Jul-2008 21:53:34 High 65.03 025320 13-Apr-2008 17:36:18 High 66.49 This is the file I'm interest in matching up.
K# ParoleIN ParoleOUT Status cohort SecureIn SecureOut Status1
025319 14-Jan-2010 14:31:00 16-Feb-2010 06:17:00 7 3 28-Aug-2009 11:43:00 14-Jan-2010 14:31:00 2
025319 9-Apr-2009 11:35:00 14-Aug-2009 13:20:00 7 2 24-Dec-2008 15:54:00 9-Apr-2009 11:35:00 2 025319 4-Dec-2008 16:20:00 10-Dec-2008 09:06:00 7 1 18-Sep-2008 08:34:00 4-Dec-2008 16:20:00 2 025320 12-Dec-2008 08:20:00 29-Jan-2009 08:28:00 7 1 20-Dec-2007 16:08:00 12-Dec-2008 08:20:00 2 So for instance, Youth #25319 came in three time. The first time was Sept 18, 2008 so I would need the Sept 16th Low 44.97 record. Then he exited on Dec 4,2008 so I would like to match it up
with Dec 17th Low 35.47 record...then I would need to go to the next one.
I hope this all makes senses. I'm really lost...any assistance would be nice.
Thanks.
Stella Vasquez, Planner
Research & Development
1624 W Adams
Phoenix, AZ 85007
(602) 542-2272 work
**The information contained in this communication is privileged and confidential and is intended solely for the individual[s] and/or entities named herein. This information is not to be disseminated. If you have received this message in error, please reply to the sender and notify the sender of the error and then permanently delete the message and sent item. Thank you.** |
|
In reply to this post by Stella Vasquez
Shalom
To solve your problem you need to do a many to many match . SPSS can not do that kind of match directly . Here is a syntax to do that match and find the risk dates with the smaller absolute difference from the SecureIn SecureOut dates . dataset close all. data list FIXED / ID 1-6 (a) RiskDate 9-19(edate) RiskLevel 30-35(a) FinalScore 40-45(f) . begin data 025319 9-Feb-2010 08:16:53 High 63.27 025319 12-Dec-2009 23:06:11 Low 38.47 025319 28-Aug-2009 21:26:02 Low 42.97 025319 29-Jul-2009 07:37:00 Low 47.77 025319 30-Apr-2009 18:38:28 Low 41.87 025319 6-Apr-2009 22:06:10 Low 42.57 025319 17-Dec-2008 17:04:35 Low 35.47 025319 16-Sep-2008 16:16:38 Low 44.97 025319 16-Jun-2008 13:32:32 Medium 51.73 025319 24-Mar-2008 13:33:40 Medium 51.73 025319 24-Feb-2008 18:04:11 Medium 51.73 025319 28-Nov-2007 10:12:13 Low 38.6 025319 23-Feb-2006 16:59:33 Medium 53.07 025320 2-Jan-2009 10:10:02 Medium 53.07 025320 12-Oct-2008 00:07:12 Medium 53.07 025320 14-Jul-2008 21:53:34 High 65.03 025320 13-Apr-2008 17:36:18 High 66.49 end data . execute . sort cases by id . dataset name risk . data list FIXED / ID 1-6(a) ParoleIN 9-19 (edate) ParoleOUT 34-44(edate) Status 57 cohort 63 SecureIn 69-79(edate) SecureOut 92-102(edate) Status1 118 . begin data 025319 14-Jan-2010 14:31:00 16-Feb-2010 06:17:00 7 3 28-Aug-2009 11:43:00 14-Jan-2010 14:31:00 2 025319 9-Apr-2009 11:35:00 14-Aug-2009 13:20:00 7 2 24-Dec-2008 15:54:00 9-Apr-2009 11:35:00 2 025319 4-Dec-2008 16:20:00 10-Dec-2008 09:06:00 7 1 18-Sep-2008 08:34:00 4-Dec-2008 16:20:00 2 025320 12-Dec-2008 08:20:00 29-Jan-2009 08:28:00 7 1 20-Dec-2007 16:08:00 12-Dec-2008 08:20:00 2 end data . sort cases by id . add files file= * / by id/ first=first . if first eq 1 #seq =0 . compute #seq=#seq+1 . compute seq=#seq . dataset name inout . SORT CASES BY ID seq. DATASET COPY wide . DATASET ACTIVATE wide. CASESTOVARS /ID=ID /INDEX=seq /DROP = ParoleIN ParoleOUT Status cohort SecureIn SecureOut Status1 /GROUPBY=VARIABLE. match files table= wide / file=risk / by id . execute . VARSTOCASES /MAKE time FROM first.1.00 first.2.00 first.3.00 /INDEX=Index1(3) /KEEP=ID RiskDate RiskLevel FinalScore /NULL=KEEP. rename var index1=seq . sort cases by id seq . dataset name long . match files table= inout / file=long / by id seq. compute daysin =abs(datedeff(SecureIn , RiskDate,'days') ). compute daysout =abs(datedeff(SecureOut , RiskDate,'days') ). execute . AGGREGATE /OUTFILE=* MODE=ADDVARIABLES /BREAK=id seq /daysin_min=MIN(daysin) /daysout_min=MIN(daysout). select if daysin_min=daysin or daysout_min=daysout. execute . Hillel Vardi BGU Stella Vasquez wrote: > Hello there: > > I really do need some help. I need to determine what the youths risk > score was at entry and at exit. > Our youth are given a risk assessment once a month while in our > custody. This is what the risk file looks like: > > K# > RiskDate RiskLevel FinalScore > 025319 9-Feb-2010 > 08:16:53 High 63.27 > 025319 12-Dec-2009 > 23:06:11 Low 38.47 > 025319 28-Aug-2009 > 21:26:02 Low 42.97 > 025319 29-Jul-2009 > 07:37:00 Low 47.77 > 025319 30-Apr-2009 > 18:38:28 Low 41.87 > 025319 6-Apr-2009 > 22:06:10 Low 42.57 > 025319 17-Dec-2008 > 17:04:35 Low 35.47 > 025319 16-Sep-2008 > 16:16:38 Low 44.97 > 025319 16-Jun-2008 > 13:32:32 Medium 51.73 > 025319 24-Mar-2008 > 13:33:40 Medium 51.73 > 025319 24-Feb-2008 > 18:04:11 Medium 51.73 > 025319 28-Nov-2007 > 10:12:13 Low 38.6 > 025319 23-Feb-2006 > 16:59:33 Medium 53.07 > 025320 2-Jan-2009 > 10:10:02 Medium 53.07 > 025320 12-Oct-2008 > 00:07:12 Medium 53.07 > 025320 14-Jul-2008 > 21:53:34 High 65.03 > 025320 13-Apr-2008 > 17:36:18 High > 66.49 > > This is the file I'm interest in matching up. > > K# > ParoleIN ParoleOUT Status > cohort SecureIn SecureOut Status1 > 025319 14-Jan-2010 14:31:00 16-Feb-2010 06:17:00 7 3 > 28-Aug-2009 11:43:00 14-Jan-2010 14:31:00 2 > 025319 9-Apr-2009 11:35:00 14-Aug-2009 13:20:00 7 2 > 24-Dec-2008 15:54:00 9-Apr-2009 11:35:00 2 > 025319 4-Dec-2008 16:20:00 10-Dec-2008 09:06:00 7 1 > 18-Sep-2008 08:34:00 4-Dec-2008 16:20:00 2 > 025320 12-Dec-2008 08:20:00 29-Jan-2009 08:28:00 7 1 > 20-Dec-2007 16:08:00 12-Dec-2008 08:20:00 2 > > > So for instance, Youth #25319 came in three time. The first time was > Sept 18, 2008 so I would need the Sept 16th Low 44.97 record. Then he > exited on Dec 4,2008 so I would like to match it up with Dec 17th Low > 35.47 record...then I would need to go to the next one. > > > I hope this all makes senses. I'm really lost...any assistance would > be nice. > > Thanks. > > Stella Vasquez, Planner > Research & Development > 1624 W Adams > Phoenix, AZ 85007 > (602) 542-2272 work > > ------------------------------------------------------------------------ > **The information contained in this communication is privileged and > confidential and is intended solely for the individual[s] and/or > entities named herein. This information is not to be disseminated. If > you have received this message in error, please reply to the sender > and notify the sender of the error and then permanently delete the > message and sent item. Thank you.** ===================== 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 |
| Free forum by Nabble | Edit this page |
