Merging files - duplicate cases and missing cases

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

nnmegibp
Posts: 3
Joined: Mon Feb 03, 2014 10:43 am

Merging files - duplicate cases and missing cases

Postby nnmegibp » Mon Feb 03, 2014 11:05 am

Hi,
I could really need some help with merging files. I tried to use the syntax I found here: http://www.ats.ucla.edu/stat/spss/modules/merge.htm but for some reason all I get is error messages.

I have one main file (let's call it original.sav) with unique case IDs that I want to merge with three other files. The unique ID for each case is used in the other files as well, but:
1) In two of the files (let's call them file1.sav and file2.sav), not all the cases in the original file are there (as they have not had the event I'm looking at), and some are listed several times (because they have had multiple events, I want all those events in the final, merged file). So what I need after merging the original file with one of the new files is: ID - (variables associated with the first event, v1, v2, v3 etc) - (variables associated with the second event v1, v2, v3 etc) - (etc) for each case, in one row. Not to have the same person listed several times, over several rows, as they are now. This is a one to many merge, as far as I understand?
2) In one of the files (let's call it file3.sav), there is only one row per case, which should've made this a lot easier. However, there seemed to be 10 extra cases that are not in the main file. I checked for duplicates, and I found 12 cases that were listed twice (the variables in question are for education). When deleting their double entries, I was left with two more cases in the original file than there are in file3.sav. After sorting the cases, I was still unable to use the "merge files" option in the "data" menu, I guess because of those two cases? This should've been a one-to-one merge, but those two cases mess it up, I suppose?
nnmegibp
Posts: 3
Joined: Mon Feb 03, 2014 10:43 am

Re: Merging files - duplicate cases and missing cases

Postby nnmegibp » Mon Feb 03, 2014 12:40 pm

I can add that in 2) I identified the two missing cases in the file manually. I inserted their IDs (with missing data on the variables), then sorted the files and tried to use the Merge files -> add variables menu. Which I thought would work, as the same IDs should be in both files now. But I got an error message saying "variables are different type or length" when I tried to move the ID variable into the "key variables" box. Do you have any idea what might be wrong?

I guess it's just one thing after another today. :roll:
nnmegibp
Posts: 3
Joined: Mon Feb 03, 2014 10:43 am

Re: Merging files - duplicate cases and missing cases

Postby nnmegibp » Mon Feb 03, 2014 12:53 pm

And when I use syntax:

MATCH FILES FILE="hunt2.sav"
/FILE="utd4.sav"
/BY ID.
EXECUTE.

- instead of the graphical interface, I get this error message:


MATCH FILES FILE="hunt2.sav"
/FILE="utd4.sav"
/BY ID.

>Error # 63 in column 18. Text: hunt2.sav
>The file does not exist.
>Execution of this command stops.

>Error # 63 in column 9. Text: utd4.sav
>The file does not exist.

>Note # 5146
>There is no working file to restore. You must define a working file before
>proceeding with your analysis.
EXECUTE.
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

Re: Merging files - duplicate cases and missing cases

Postby GerineL » Mon Feb 10, 2014 11:18 am

nnmegibp wrote:And when I use syntax:

MATCH FILES FILE="hunt2.sav"
/FILE="utd4.sav"
/BY ID.
EXECUTE.

- instead of the graphical interface, I get this error message:


MATCH FILES FILE="hunt2.sav"
/FILE="utd4.sav"
/BY ID.

>Error # 63 in column 18. Text: hunt2.sav
>The file does not exist.
>Execution of this command stops.

>Error # 63 in column 9. Text: utd4.sav
>The file does not exist.

>Note # 5146
>There is no working file to restore. You must define a working file before
>proceeding with your analysis.
EXECUTE.
try using the whole path instead of just hunt2.sav

Who is online

Users browsing this forum: No registered users and 2 guests

cron