SPSS:使用DO REPEAT添加两个变量

时间:2021-10-06 22:44:35

I am new to SPSS, the world of statistics and new to this forum. I am doing research in conjunction with my Masters Degree and running into a bit of a problem and looking for some help. Yes, I could hire a consultant, but view this part of the learning process, and would like to see if I cannot master this - with your help of course.....

我是SPSS的新手,统计世界和这个论坛的新手。我正在与我的硕士学位一起进行研究,遇到一些问题,并寻求一些帮助。是的,我可以聘请一名顾问,但是要查看这部分学习过程,并希望看看我是否能够掌握这一点 - 当然,在你的帮助下......

I am looking to add: q1 and q51 q2 and q52 q3 and q53 etc.... through to q50 and q100

我想补充:q1和q51 q2和q52 q3和q53等......直到q50和q100

The new variable names currently are TOTAL1 to TOTAL50, but could be anything. Q1 to q100 exist and are consecutive TOTAL1 to TOTAL 50 exists and are consecutive

新的变量名称目前是TOTAL1到TOTAL50,但可以是任何东西。 Q1到q100存在且连续TOTAL1到TOTAL 50存在并且是连续的

I have tried:

我试过了:

do repeat x = q1 to q50 
         /y = q51 to q100 
         /z = TOTAL1 to TOTAL50. 
COMPUTE z = x + y.
end repeat . 
EXECUTE.

But getting the following in the output:

但在输出中获得以下内容:

Error # 4502 in column 11. Text: = An equals sign appears in a variable or value list where it is not expected. It will be ignored. Execution of this command stops.

第11列中的错误#4502。文本:=等号出现在变量或值列表中,不符合预期。它会被忽略。执行此命令停止。

Error # 4508 in column 15. Text: + Unrecognized text appears on the DO REPEAT command. It will be ignored. EXECUTE. do repeat x = q1 to q50 / y = q51 to q100 / z = TOTAL1 to TOTAL50 COMPUTE z = x + y end repeat .

第15列中的错误#4508。文本:+ DO REPEAT命令上出现无法识别的文本。它会被忽略。执行。 do repeat x = q1 to q50 / y = q51 to q100 / z = TOTAL1 to TOTAL50 COMPUTE z = x + y end repeat。

Error # 4502 in column 11. Text: = An equals sign appears in a variable or value list where it is not expected. It will be ignored. Execution of this command stops.

第11列中的错误#4502。文本:=等号出现在变量或值列表中,不符合预期。它会被忽略。执行此命令停止。

Error # 4508 in column 15. Text: + Unrecognized text appears on the DO REPEAT command. It will be ignored. EXECUTE.

第15列中的错误#4508。文本:+ DO REPEAT命令上出现无法识别的文本。它会被忽略。执行。

Is this the best way of doing this? Can anyone spot a syntax error?

这是最好的方法吗?有人能发现语法错误吗?

I am using SPSS v. 20.

我正在使用SPSS v.20。

1 个解决方案

#1


Try this

do repeat x = q1 to q50 
         /y = q51 to q100 
         /z = TOTAL1 to TOTAL50. 
- COMPUTE z = x + y.  /*i just added a minus sign before the compute./
end repeat . 
EXECUTE.

#1


Try this

do repeat x = q1 to q50 
         /y = q51 to q100 
         /z = TOTAL1 to TOTAL50. 
- COMPUTE z = x + y.  /*i just added a minus sign before the compute./
end repeat . 
EXECUTE.