SPSS - 使用 if-then 从两个字符串计算新变量
SPSS - calculate new variable from two string using if-then
我需要开发一个语句,根据它们的值和缺失值从两个列中提取字符串值。例如。
- COL-A,COL-B,NEW_VAR
- AA, BB, AA
- ___,抄送,抄送
- DD, __, DD
- __, __, __
我知道这是一个简单的陈述,但我今天似乎无法理解。
应该这样做:
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.
我需要开发一个语句,根据它们的值和缺失值从两个列中提取字符串值。例如。
- COL-A,COL-B,NEW_VAR
- AA, BB, AA
- ___,抄送,抄送
- DD, __, DD
- __, __, __
我知道这是一个简单的陈述,但我今天似乎无法理解。
应该这样做:
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.