2017-05-03 103 views
1

我想合併不同的SPSS文件。付費表示不同的人。這些文件還包含指示測量時刻的變量ID。因此ID = 1意味着數據是測量結果1(ID = 2;測量2等)。但是,並非所有數據文件都包含相同的測量時刻。通過合併SPSS中的文件合併添加個案並添加變量

我已經閱讀下面的文章,但是這並沒有完全回答我的問題: SPSS - merging files with duplicate cases of ID variable and new cases/variables

實例數據文件

數據文件1:

PAID ID X1 X2 X3 X4 
1  1 3 4 4 5 
2  1 3 4 5 6 
3  1 3 4 4 6 
4  1 . . . . 

數據文件2:

PAID ID X5 X6 X7 
1  1 1 1 2 
1  2 1 2 1 
2  1 1 2 2 
2  2 2 2 2 
3  1 1 1 1 
3  2 1 . . 
4  1 1 1 1 
4  2 2 2 2 

我想要th e以下結果:

PAID ID X1 X2 X3 X4 X5 X6 X7 
1  1 3 4 4 5 1 1 2 
1  2 . . . . 1 2 1 
2  1 3 4 5 6 1 2 2 
2  2 . . . . 2 2 2 
3  1 3 4 4 6 1 1 1 
3  2 . . . . 1 . . 
4  1 . . . . 1 1 1 
4  2 . . . . 2 2 2 

我想我必須使用函數add case和add variables的一些組合。但是,這在SPSS中可能嗎?如果是這樣,我該怎麼做?

在此先感謝!

回答

0

這將做的工作:

match files /file='path\DataFile1.sav' /file='path\DataFile2.sav'/by paid id. 

請注意,雖然,這兩個文件需要由paidid運行賽前排序。

要與樣品的數據表明:

*first preparing demonstration data. 
DATA LIST list/paid id x1 to x4 (6f). 
begin data. 
1,1,3,4,4,5 
2,1,3,4,5,6 
3,1,3,4,4,6 
4,1, , , , 
end data. 
* instead of creating the data, you can can get your original data: 
* get file="path\file name 1.sav". 
sort cases by paid id. 
dataset name DataFile1. 


DATA LIST list/paid id x5 to x7 (5f). 
begin data. 
1,1,1,1,2 
1,2,1,2,1 
2,1,1,2,2 
2,2,2,2,2 
3,1,1,1,1 
3,2,1, , 
4,1,1,1,1 
4,2,2,2,2 
end data. 
sort cases by paid id. 
dataset name DataFile2. 

match files /file=DataFile1 /file=DataFile2/by paid id. 
exe. 

的結果是這樣的:

paid id x1 x2 x3 x4 x5 x6 x7 
1 1 3 4 4 5 1 1 2 
1 2     1 2 1 
2 1 3 4 5 6 1 2 2 
2 2     2 2 2 
3 1 3 4 4 6 1 1 1 
3 2     1  
4 1     1 1 1 
4 2     2 2 2 
+0

非常感謝你。這對我有很大的幫助。 –