2012-09-10 35 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用于从长整型变为宽整型。