match two files (one to many options)

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

match two files (one to many options)

leonleo
Hi, I have two files which need to be merged together. They have different number of cases. I have tried to explian the problem in the following example;

First File,
HID     Dad    Income
1       A       1000
2       B       3000
3       C       4000

Second File,
HID     Kid      Age
1        X        10
2        Y        12
3        Z        15
2        XX      16
1        YY      17

Now in the example I have Dads info and Kids info for each house where each dad has more than 1 kid. When I'm using the Data> Merge Files> Add Variables it is only adding value for the 1st kid and not the following ones.

Essentially, I want to have an output like

HID     Kid      Age   Dad    Income
1        X        10      A       1000
2        Y        12      B       3000
3        Z        15      C       4000
2        XX      16      B       3000
1        YY      17      A       1000

Any help would be much appreciated.
Reply | Threaded
Open this post in threaded view
|

Re: match two files (one to many options)

Bruce Weaver
Administrator
In the documentation for MATCH FILES, see the distinction between /FILE and /TABLE.  See also the one-to-many example here:  http://www.ats.ucla.edu/stat/spss/modules/merge.htm.

HTH.


leonleo wrote
Hi, I have two files which need to be merged together. They have different number of cases. I have tried to explian the problem in the following example;

First File,
HID     Dad    Income
1       A       1000
2       B       3000
3       C       4000

Second File,
HID     Kid      Age
1        X        10
2        Y        12
3        Z        15
2        XX      16
1        YY      17

Now in the example I have Dads info and Kids info for each house where each dad has more than 1 kid. When I'm using the Data> Merge Files> Add Variables it is only adding value for the 1st kid and not the following ones.

Essentially, I want to have an output like

HID     Kid      Age   Dad    Income
1        X        10      A       1000
2        Y        12      B       3000
3        Z        15      C       4000
2        XX      16      B       3000
1        YY      17      A       1000

Any help would be much appreciated.
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: match two files (one to many options)

leonleo
In reply to this post by leonleo
Thanks for your response.

I have tried the syntax following the link and it partially worked. The output file just manage to add the variables only not the data. Also in the status bar it says ''Transformations pending''.

any idea?
Reply | Threaded
Open this post in threaded view
|

Re: match two files (one to many options)

Bruce Weaver
Administrator
Add an EXECUTE command.


leonleo wrote
Thanks for your response.

I have tried the syntax following the link and it partially worked. The output file just manage to add the variables only not the data. Also in the status bar it says ''Transformations pending''.

any idea?
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Tom
Reply | Threaded
Open this post in threaded view
|

Automatische Antwort: match two files (one to many options)

Tom


Besten Dank für Ihr Mail. Ich bin bis am 11. Februar 2013 nur an einzelnen Tagen anwesend und werde den Posteingang nur sporadisch überprüfen.


Mit freundlichen Grüssen

Thomas Balmer
Reply | Threaded
Open this post in threaded view
|

Re: match two files (one to many options)

leonleo
In reply to this post by Bruce Weaver
If I want to add a condition for this match files (to ensure the mothers ID
are same in the example above) I understand I have to use a IF command. I'm
planning the following,

Match files
/file "kids file"
/table "dads file"
/by HID.
IF (mother = mother)
Execute





--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/match-two-files-one-to-many-options-tp5721033p5721050.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