Problem in Merging Data

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

chesterkam
Posts: 3
Joined: Fri Sep 23, 2011 4:58 pm

Problem in Merging Data

Postby chesterkam » Fri Sep 23, 2011 5:05 pm

Hi all,

I have two datasets with the following structure:

DATASET 1

participant_id
1
1
1
1
2
2
3
3
3
3
3

DATASET 2

participant_id
1
2
3

Overall there are thousands of participants in both dataset. Participants in dataset 1 have multiple lines because I will conducting Linear Mixed Modeling.

When I merge the two dataset together, SPSS complains that each participant in dataset 1 does not have an unique participant id. Can I still merge the two datasets into one?

Thanks for your help!

Chester
statman
Administrator
Posts: 2700
Joined: Tue Jun 12, 2007 12:08 pm
Location: Florida, USA

Re: Problem in Merging Data

Postby statman » Sun Sep 25, 2011 11:59 am

Are you wanting to ADD the 2nd dataset cases or APPEND the cases to the 1st?

Check into both options to see which is viable; the APPEND will give you issues so you might need to split out cases from the 1st then match the 2nd
See the note below

NOTE: Please read the Posting Guidelines and always tell us your OS, the SPSS version and information about your study and data!

Statman
Statistical Services
chesterkam
Posts: 3
Joined: Fri Sep 23, 2011 4:58 pm

Re: Problem in Merging Data

Postby chesterkam » Wed Sep 28, 2011 2:57 pm

Actually I want to add variables from dataset 2 onto dataset 1. The structure of my dataset is as follow:

participant_id week
1 1
1 2
1 3
1 4
2 1
2 2
3 1
3 3
3 4
3 5
3 7
DATASET 2

participant_id PersonalityScores
1 4.2
2 3.7
3 2.1

I want to have every line for participant #1 in dataset 1 to have the personailty score of 4.2, every line for participant #2 in dataset 1 to have the personality score of 3.7, and every line for participant #3 in dataset 1 to have the personality score of 2.1.

I have a lot of participants in total. Therefore, what is the easiest way to do so in SPSS (except inputting the data one by one on dataset 1 by hand)?

Thanks, again!

Chester
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

Re: Problem in Merging Data

Postby GerineL » Wed Sep 28, 2011 4:16 pm

look into merge.

Take file 1 as a start and merge file 2.

click the option "non-active is keyed table"
chesterkam
Posts: 3
Joined: Fri Sep 23, 2011 4:58 pm

Re: Problem in Merging Data

Postby chesterkam » Wed Sep 28, 2011 4:59 pm

Thanks for your reply. I tried and then SPSS gave me the following error message:

>Error # 5131
>Duplicate key on a TABLE file. Each case on a TABLE file in MATCH FILES must
>be uniquely identified by the BY variables.
>Execution of this command stops
Analyst Techy
Moderator
Posts: 22
Joined: Mon Apr 27, 2009 2:19 am
Location: Melbourne, Australia

Re: Problem in Merging Data

Postby Analyst Techy » Thu Sep 29, 2011 5:01 am

Hi chesterkam.

Backup your work first.

Activate the offending SAV file used as a lookup and select the following menu items
Data>Identify Duplicate Cases and select the grouping variable and follow the prompt. The end result will be a new variable called either PrimaryFirst or PrimaryLast.

Then

Data>Select Cases e.g. PrimaryFirst = 0.

Good Luck!
Analyst Techy

NOTES:
Any solutions I provide on this forum are free of charge, donations go towards the maintenance of the unaffiliated SPSS forum.
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

Re: Problem in Merging Data

Postby GerineL » Thu Sep 29, 2011 7:52 am

what probably went wrong is that you took this file as a start

ID
1
2
3


instead of this file

ID
1
1
1
2
2
2
3
3
3


start with the last file, click merge etc. there.
If you did it right, do the duplicate ID thing.

Who is online

Users browsing this forum: No registered users and 1 guest

cron