2012-09-10 36 views
1

我有一項調查的數據。現在的問題是這樣的:如何在SPSS中重塑數據

Did you do any of the following activities during your PhD 

          Yes, paid by my school. Yes, paid by me. No. 

Attended an internationl conference? 
Bought textbooks? 

的數據自動保存在電子表格中這樣說:

id conf.1 conf.2 conf.3 text.1 text.2 text.3 

1 1        1 
2   1    1 
3     1  1 
4     1     1 
5    

這意味着參與者1出席了她的大學付出了會議;參加者2參加了他所支付的會議,參與者3沒有參加。

我要合併CONF.1,CONF.2和CONF.3和text.1,text.2和text.3單變量

id new.conf new.text 

1 1  2 
2 2  1 
3 3  1 
4 3  3 

where the number now respresents the categories of the survey question 

Thanks for your help 
+0

我找到了答案http://www.arts.unsw.edu.au/gargyrous/extra_chapters/SPSSMultipleResponseCommand.pdf –

回答

0

我不知道你給多說明迴應集(你在你的問題的評論中你link to)真的是你想要的。在本例中,您根本不需要重新整理數據,只需使用簡單的DO REPEAT命令即可使您的new.confnew.text變量足夠。下面的例子:

data list free /id conf.1 conf.2 conf.3 text.1 text.2 text.3. 
begin data 
1 1 0 0 0 1 0 
2 0 1 0 1 0 0 
3 0 0 1 1 0 0 
4 0 0 1 0 0 1 
5 0 0 0 0 0 0 
end data. 
dataset name conf. 
*this is to replicate missing data as specified originally. 
recode conf.1 to text.3 (0 = SYSMIS)(ELSE = COPY). 

compute new.conf = 0. 
compute new.text = 0. 
do repeat conf_list = conf.1 to conf.3 /text_list = text.1 to text.3 /#i = 1 to 3. 
    if conf_list = 1 new.conf = #i. 
    if text_list = 1 new.text = #i. 
end repeat. 

命令list all然後產生如下輸出(注意我是如何初始化的變量值設置爲0,不是真的需要,但怎麼我平時對待事物):

id conf.1 conf.2 conf.3 text.1 text.2 text.3 new.conf new.text 

1.00  1.00  .  .  .  1.00  .  1.00  2.00 
2.00  .  1.00  .  1.00  .  .  2.00  1.00 
3.00  .  .  1.00  1.00  .  .  3.00  1.00 
4.00  .  .  1.00  .  .  1.00  3.00  3.00 
5.00  .  .  .  .  .  .  .00  .00 

號碼的案例閱讀:5案件數量列表:5

這是可能的你想重塑的數據,雖然如果conf和文本lis t變量是互斥的,沒有理由。如果您需要重新整形數據,請參閱指令VARSTOCASES的幫助以將其從整形變爲長整型,並將CASESTOVARS用於從長整型變爲寬整型。