设有两列
Name Score
张按 90
李四 100
王一 80
【转换】》【计算】 输入:
新变量score11
表达式: Score - lag(score)
数据集合中将有一新列: score11 分别为:
。。
20
-20
可以试着在spss文件》新建》语法》中输入下面代码:然后运行:就知道如何做两行的减法了.
DATA LIST FREE / id (A4) exam1 exam2 exam3.
BEGIN DATA
101 98 100 78
102 76 45 67
103 45 68 91
END Data.
COMPUTE Row2_row1=exam1-lag(exam1).
COMPUTE Row2_row2=exam2-lag(exam2).
COMPUTE Row2_row3=exam3-lag(exam3).
EXECUTE.
结果:
ID exam1 exam 2 exm3 Row2_row1Row2_row1Row2_row1
101 98.00 100.00 78.00 . . .
102 76.00 45.00 67.00 - 22.00 -55.00 -11.00
103 45.00 68.00 91.00 -31.00 23.00 24.00
好像在《SPSS18数据分析基础与实践》这本书中有类似的代码,可以找来参考。
参见:http://www.docin.com/p-83048915.html