根据spss中的前几个字符选择案例?

时间:2020-01-03 00:28:20

标签: select spss

我想选择前3个特殊字符的案例。

例如前三个字符包含356 | else build_aux (DistMap.find x map)::acc source (DistMap.find x map) ^^^^^^^^^^^^^^^^^^^^ Error: This expression has type 'a but an expression was expected of type 'a list The type variable 'a occurs inside 'a list 的情况。

整个值的长度可以变化。例如"I22""I228",但它们具有共同的前三个字符"I2279"

我通常使用"I22"

但这很乏味,因为我必须输入compute variable_name= "I228".的所有变体,例如"I22""I228"等。

如果我可以仅基于相同的前三个字符来选择案例,那就容易得多了

1 个答案:

答案 0 :(得分:1)

您可以使用char.cubstr函数来查找字符串变量中的前三个字符。例如:

if char.substr(variable_name,1,3)="I22" keep_this=1.

或:

select cases if char.substr(variable_name,1,3)="I22".
相关问题