如果spss中有任何命令,是否可以使用嵌套?例如
if any(1, a to c) and if (1, s to x) xx=1.
当然可以,但是您的语法不太正确。if (any(1, a to c) and any(1, s to x)) xx=1。
if 表达式可以任意复杂,但必须是表达式。if 部分是一个语句。
高温高压
只是为了提供一个澄清嵌套部分的答案,这是一个使用do if
而不是if
.
do if any(1, a to c).
do if any(1, s to x).
compute xx=1.
end if.
end if.
a
此代码查找在任何变量上至少有一次得分为 1 的行c
。仅在这些行中,它会找到在任何变量上至少有一次得分为 1 的s
行x
。通过第一个语句并随后通过第二个语句的行被分配xx=1
。
它产生与以下相同的结果:
if any(1, a to c)
and
any(1, s to x) xx=1.
但是,以下会产生不同的结果:
if any(1, a to c) xx=1.
if any(1, s to x) xx=1.
这本质上与在 2 个条件语句之间使用or的含义相同
if any(1, a to x)
or
any(1, s to x) xx=1.