2017-03-17 108 views
2

我的數據是這樣的:SPSS - 變量的情況下

Person Region Grapes Apples Bananas 
Bob IV  4  2  1 
Jane II  0  1  2 

我需要重組(瓦爾案件?)返回一個記錄水果的人有各自的個數,如:

Person Region Fruit 
Bob IV  Grapes 
Bob IV  Grapes 
Bob IV  Grapes 
Bob IV  Grapes 
Bob IV  Apples 
Bob IV  Apples 
Bob IV  Bananas 
Jane II  Apples 
Jane II  Bananas 
Jane II  Bananas 

下面的代碼將返回這一點,這是更近了一步,但也不能令人信服:

Person Region Fruit Count 
Bob IV  Grapes 4 
Bob IV  Apples 2 
Bob IV  Bananas 1 
Jane II  Apples 1 
Jane II  Bananas 2 

VARSTOCASES /MAKE Count FROM Grapes Apples Bananas /INDEX=Fruit(Count) /KEEP=Person Region /NULL=KEEP.

有什麼建議嗎?

回答

2

是的,這是代碼的第一步!接下來,只需添加這片:

loop # = 1 to Count. 
xsave outfile = 'c:/personal/disaggregated.sav'/drop count. 
end loop. 

這就是你所需要的 - 它會遍歷並重復根據您Count變量的值。

乾杯, Valeria