【问题标题】:SPSS: use a loop to compute new variables for different time pointsSPSS:使用循环计算不同时间点的新变量
【发布时间】:2021-03-04 10:44:50
【问题描述】:

我的 SPSS 数据集包括为不同时间测量点收集的变量。我想用循环为不同的时间测量点(t1、t2、t3 等)反转我的变量。

有没有办法为不同的时间测量点重复相同的命令,例如通过在循环中将 X 替换为 t1、t2、t3 等?

COMPUTE variable_1_X_inv = 5-variable_1_X
EXE.

感谢您的帮助!

【问题讨论】:

    标签: loops spss


    【解决方案1】:

    假设这些变量在数据集中是连续的,这将完成这项工作:

    do repeat orig=variable_1_1 to variable_1_50 / inv=variable_1_inv_1 to variable_1_inv_50.
       compute inv = 5 - orig.
    end repeat.
    

    请注意,variable_1_1_inv to variable_1_50_inv工作,但如果您可以接受名称末尾的索引,如上所述,一切都应该很好。

    注意 2:您还应该查找 loopvector,这在类似情况下可能会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-10-21
      • 1970-01-01
      • 1970-01-01
      • 2016-05-29
      • 2018-07-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多