Matching Assistance

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

Matching Assistance

cfishernyc
I need to be able, in the following file formats, to match for each ID key variable in FILE 2, the housing location and date variables to every row in FILE1. The example of what I need is at the end...suggestions are very much appreciated.

These are the structures of the two files I need to match:

File 1

ID       Incd#      Incddate   EventCode
1        1             1/1/09      3
1        1             1/1/09      2
1        2             2/1/09      2
2        3             3/1/09      2

File 2

ID       Housing       AssignDate
1        Hallb           12/31/08
1        Hallc           1/5/09
1        Halla           1/25/09
2        Hallb           1/15/09  


DESIRED Final file

ID      Incd#   Incddate   EventCode    Housing   AssignDate
1       1          1/1/09     3                 Hallb       12/31/09
                                                     Hallc       1/5/09
                                                     Halla       1/25/09
1       1          1/1/09     2                 Hallb       12/31/09
                                                     Hallc        1/5/09
                                                     Halla       1/25/09    
1       2          2/1/09     2                 Hallb        12/31/09
                                                    Hallc         1/5/09
                                                    Halla         1/25/09                  
Reply | Threaded
Open this post in threaded view
|

Re: Matching Assistance

Maguin, Eugene
Cfisher,

There are several things that are not clear about what you want to do. The
example shows that you want to get 9 records for id=1. But, you do not show
the file 1 info being carried across the six new records file 1 records. I
think your result should look like

ID      Incd#   Incddate   EventCode    Housing   AssignDate
1       1          1/1/09     3         Hallb       12/31/09
1       1          1/1/09     3         Hallc       1/5/09
1       1          1/1/09     3         Halla       1/25/09
1       1          1/1/09     2         Hallb       12/31/09
1       1          1/1/09     2         Hallc        1/5/09
1       1          1/1/09     2         Halla        1/25/09
1       2          2/1/09     2         Hallb       12/31/09
1       2          2/1/09     2         Hallc        1/5/09
1       2          2/1/09     2         Halla        1/25/09

Do you disagree? Or, is the way you wrote result a 'shorthand' notation? I
think this has to be gotten sorted out first.

Gene Magin



These are the structures of the two files I need to match:

File 1
ID       Incd#      Incddate   EventCode
1        1             1/1/09      3
1        1             1/1/09      2
1        2             2/1/09      2
2        3             3/1/09      2

File 2
ID       Housing       AssignDate
1        Hallb           12/31/08
1        Hallc           1/5/09
1        Halla           1/25/09
2        Hallb           1/15/09


DESIRED Final file

ID      Incd#   Incddate   EventCode    Housing   AssignDate
1       1          1/1/09     3         Hallb       12/31/09
                                        Hallc       1/5/09
                                        Halla       1/25/09
1       1          1/1/09     2         Hallb       12/31/09
                                        Hallc        1/5/09
                                        Halla        1/25/09
1       2          2/1/09     2         Hallb       12/31/09
                                        Hallc        1/5/09
                                        Halla        1/25/09

--
View this message in context:
http://www.nabble.com/Matching-Assistance-tp23259685p23259685.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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

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

Re: Matching Assistance

cfishernyc
Sorry for the confusion Gene, thanks for letting me know.

Yes, I was trying to show what you typed out.

The idea being, in essence. For each ID number, there will be multiple admission numbers, and for each ID-Admission# pair, they could be multiple Incd# (incidents).

Then, for each admission #, there will be a set of housing location assignment dates. What I want to end up with, is, for each instance where there is the same ID#, the same Admission#, but a different Incd#, i need the entire housing history for that Admission to be matched against that combo as many times as there are housing changes.

The need is, I need to know in which housing location a participant was when they had an incident. So, if you see a way to compare each incident date to every housing date for that participant on that admission, without doing a merge like that, that would be helpful too.


Gene Maguin wrote
Cfisher,

There are several things that are not clear about what you want to do. The
example shows that you want to get 9 records for id=1. But, you do not show
the file 1 info being carried across the six new records file 1 records. I
think your result should look like

ID      Incd#   Incddate   EventCode    Housing   AssignDate
1       1          1/1/09     3         Hallb       12/31/09
1       1          1/1/09     3         Hallc       1/5/09
1       1          1/1/09     3         Halla       1/25/09
1       1          1/1/09     2         Hallb       12/31/09
1       1          1/1/09     2         Hallc        1/5/09
1       1          1/1/09     2         Halla        1/25/09
1       2          2/1/09     2         Hallb       12/31/09
1       2          2/1/09     2         Hallc        1/5/09
1       2          2/1/09     2         Halla        1/25/09

Do you disagree? Or, is the way you wrote result a 'shorthand' notation? I
think this has to be gotten sorted out first.

Gene Magin



These are the structures of the two files I need to match:

File 1
ID       Incd#      Incddate   EventCode
1        1             1/1/09      3
1        1             1/1/09      2
1        2             2/1/09      2
2        3             3/1/09      2

File 2
ID       Housing       AssignDate
1        Hallb           12/31/08
1        Hallc           1/5/09
1        Halla           1/25/09
2        Hallb           1/15/09


DESIRED Final file

ID      Incd#   Incddate   EventCode    Housing   AssignDate
1       1          1/1/09     3         Hallb       12/31/09
                                        Hallc       1/5/09
                                        Halla       1/25/09
1       1          1/1/09     2         Hallb       12/31/09
                                        Hallc        1/5/09
                                        Halla        1/25/09
1       2          2/1/09     2         Hallb       12/31/09
                                        Hallc        1/5/09
                                        Halla        1/25/09

--
View this message in context:
http://www.nabble.com/Matching-Assistance-tp23259685p23259685.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (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

=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (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
Reply | Threaded
Open this post in threaded view
|

Re: Matching Assistance

Maguin, Eugene
Cfisher,

I think you might better think of matching file 1 to file 2 rather than the
other way around. I may not be understanding you correctly but I think I
would restructure file 2 using casestovars so that you go from

> File 2
> ID       Housing       AssignDate
> 1        Hallb           12/31/08
> 1        Hallc           1/5/09
> 1        Halla           1/25/09
> 2        Hallb           1/15/09

To
File 2
ID Housing1 Housing2 Housing3 AssignDate1 AssignDate2 AssignDate3
1  Hallb    Hallc    Halla    12/31/08    1/5/09      1/25/09
2  Hallb                       1/15/09         .            .

Then, treat the restructured file 2 as a 'table' file using the Table
subcommand of the Match files command so that a file 2 record is 'spread
across' as many file 1 records as have a matching id.

Then, there's a couple of ways to do the next part, I think. I'd declare
housing1 to housing(n) and assigndate1 to assigndate(n) to be vectors. YOu
need to see how many housing or assigndate values that you have. Let that
value be NPairs. By the way, I assume that assigndate(i) is a date variable
and not a string.

Loop #i=1 to npairs.
+  do if (Incddate ge assign(#i)).
+     compute IncidentLocation=house(#i).
+     break.
+  end if.
End loop.

This is how I'd start. I haven't tested the code. If you have problems, I
work to fix it.

Gene Maguin



-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
cfishernyc
Sent: Monday, April 27, 2009 3:26 PM
To: [hidden email]
Subject: Re: Matching Assistance

Sorry for the confusion Gene, thanks for letting me know.

Yes, I was trying to show what you typed out.

The idea being, in essence. For each ID number, there will be multiple
admission numbers, and for each ID-Admission# pair, they could be multiple
Incd# (incidents).

Then, for each admission #, there will be a set of housing location
assignment dates. What I want to end up with, is, for each instance where
there is the same ID#, the same Admission#, but a different Incd#, i need
the entire housing history for that Admission to be matched against that
combo as many times as there are housing changes.

The need is, I need to know in which housing location a participant was when
they had an incident. So, if you see a way to compare each incident date to
every housing date for that participant on that admission, without doing a
merge like that, that would be helpful too.



Gene Maguin wrote:

>
> Cfisher,
>
> There are several things that are not clear about what you want to do. The
> example shows that you want to get 9 records for id=1. But, you do not
> show
> the file 1 info being carried across the six new records file 1 records. I
> think your result should look like
>
> ID      Incd#   Incddate   EventCode    Housing   AssignDate
> 1       1          1/1/09     3         Hallb       12/31/09
> 1       1          1/1/09     3         Hallc       1/5/09
> 1       1          1/1/09     3         Halla       1/25/09
> 1       1          1/1/09     2         Hallb       12/31/09
> 1       1          1/1/09     2         Hallc        1/5/09
> 1       1          1/1/09     2         Halla        1/25/09
> 1       2          2/1/09     2         Hallb       12/31/09
> 1       2          2/1/09     2         Hallc        1/5/09
> 1       2          2/1/09     2         Halla        1/25/09
>
> Do you disagree? Or, is the way you wrote result a 'shorthand' notation? I
> think this has to be gotten sorted out first.
>
> Gene Magin
>
>
>
> These are the structures of the two files I need to match:
>
> File 1
> ID       Incd#      Incddate   EventCode
> 1        1             1/1/09      3
> 1        1             1/1/09      2
> 1        2             2/1/09      2
> 2        3             3/1/09      2
>
> File 2
> ID       Housing       AssignDate
> 1        Hallb           12/31/08
> 1        Hallc           1/5/09
> 1        Halla           1/25/09
> 2        Hallb           1/15/09
>
>
> DESIRED Final file
>
> ID      Incd#   Incddate   EventCode    Housing   AssignDate
> 1       1          1/1/09     3         Hallb       12/31/09
>                                         Hallc       1/5/09
>                                         Halla       1/25/09
> 1       1          1/1/09     2         Hallb       12/31/09
>                                         Hallc        1/5/09
>                                         Halla        1/25/09
> 1       2          2/1/09     2         Hallb       12/31/09
>                                         Hallc        1/5/09
>                                         Halla        1/25/09
>

=====================
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