【问题标题】:SPSS - calculate new variable from two string using if-thenSPSS - 使用 if-then 从两个字符串计算新变量
【发布时间】:2018-08-23 15:53:41
【问题描述】:

我需要开发一个语句,该语句将根据它们的值和缺失值从两个列中提取字符串值。例如。

  • COL-A、COL-B、NEW_VAR
  • AA、BB、AA
  • ___,抄送,抄送
  • DD,__,DD
  • __, __, __

我知道这是一个简单的陈述,但我今天似乎无法弄清楚。

【问题讨论】:

  • 你的意思是缺失值还是空值?
  • 空值。我很抱歉。

标签: if-statement spss


【解决方案1】:

应该这样做:

string new_var(a20).
if (COL_A<>"" and COL_B<>"") or COL_B="" new_var=COL_A.
if new_var="" and COL_B<>"" new_var=COL_B.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多