0

I'm pretty embarrassed to be asking this because it seems simple but I can't figure it out.

I'm trying to create a new variable based on multiple if-then statements. For example:

 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;

I think that I may be overwriting newvar with each statement? Is that what's going on?

1 Answers1

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;
Chris J
  • 7,549
  • 2
  • 25
  • 25