0

我很尴尬地问这个问题,因为它看起来很简单,但我无法弄清楚。

我正在尝试基于多个 if-then 语句创建一个新变量。例如:

 if question1=1 then newvar=1;
 if question2=1 then newvar=2;
 if question3=1 and question4=1 then newvar=3;
 if question5 in (1 2) then newvar=4;
 if question1=2 then newvar=5;

我认为我可能会用每条语句覆盖 newvar ?这是怎么回事?

4

1 回答 1

2

You're just missing else statements :

if question1=1 then newvar=1;
else
if question2=1 then newvar=2;
else
if question3=1 and question4=1 then newvar=3;
else
if question5 in (1 2) then newvar=4;
else
if question1=2 then newvar=5;
于 2014-04-19T08:35:21.007 回答