Comparing two data files in SPSS

Deepanshu Bhalla 1 Comment
Suppose you want to compare two files to see if they are identical or not.

In SPSS, COMPARE DATASETS compares the active dataset to another dataset to check identical or mismatching values in variables.

Data File 1

Name Score1 Score2 Score3
Sam 77 68 66
Deepanshu 50 71 89
Sandy 71 91 50
Shane 55 78 89
Roger 50 97 86
Iqbal 56 63 56
Priya 88 68 93

Data File 2
Name Score1 Score2 Score3
Sam 77 68 66
Deepanshu 50 94 89
Sandy 71 91 50
Shane 55 78 89
Roger 50 74 81
Iqbal 56 63 56
Priya 81 68 92

Step 1 : Set up the above data sets in SPSS

Data File 1
Note : Edit the file path in the above syntax- "C:\Desktop\datafile1.sav".

Data File 2
Note : Edit the file path in the above syntax- "C:\Desktop\datafile2.sav".

Step 2 : Open *Data File 1* SPSS File

Step 3 : Run the following syntax

Points to note : 
1. The COMPDATASET subcommand specifies the dataset that will be compared to the active dataset.
2. Change the file path with the path where datafile2 is saved.
3. The VARIABLES subcommand specifies the variables to be compared.

Examples : 

1. If you want to compare files on the basis of Score1 variable
The VARIABLES subcommand will be : /VARIABLES Score1 .

2. If you want to compare files on the basis of two variables - Score1 and Score2
The VARIABLES subcommand will be : /VARIABLES  Score1 Score2 .

3. If you want to compare files on the basis of all the variables
The VARIABLES subcommand will be : /VARIABLES  ALL .

Output :


Related Posts
Spread the Word!
Share
About Author:
Deepanshu Bhalla

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has over 10 years of experience in data science. During his tenure, he worked with global clients in various domains like Banking, Insurance, Private Equity, Telecom and HR.

Post Comment 1 Response to "Comparing two data files in SPSS"
Next → ← Prev