gpt4 book ai didi

spss - 是否可以使用 less/greater than 运算符 IF ANY?

转载 作者:行者123 更新时间:2023-12-01 06:02:43 24 4
gpt4 key购买 nike

是否可以在 if any 函数中使用 <,> 运算符?像这样:

select if (any(>10,Q1) AND any(<2,Q2 to Q10))

最佳答案

您肯定需要创建一个辅助变量来执行此操作。

@Jignesh Sutar 的解决方案效果很好。然而,在 SPSS 中通常有多种方法来完成某项任务。

这是另一个解决方案,COUNT 命令派上了用场。重要的是要注意以下解决方案假定变量的值是整数。如果您有浮点值(例如 1.5),您将得到错误的结果。

* count occurrences where Q2 to Q10 is less then 2.
COUNT #QLT2 = Q2 TO Q10 (LOWEST THRU 1).

* select if Q1>10 and
* there is at least one occurrence where Q2 to Q10 is less then 2.
SELECT (Q1>10 AND #QLT2>0).

这种解决方案还有一个变体可以正确处理浮点变量。但我认为它不太直观。

* count occurrences where Q2 to Q10 is 2 or higher.
COUNT #QGE2 = Q2 TO Q10 (2 THRU HIGHEST).

* select if Q1>10 and
* not every occurences of (the 9 variables) Q2 to Q10 is two or higher.
SELECT IF (Q1>10 AND #QGE2<9).

注意:以#开头的变量是临时变量。它们不存储在数据集中。

关于spss - 是否可以使用 less/greater than 运算符 IF ANY?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30244234/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com