SPSS novice need help with Syntax coding for DO IF

WJU

New Member
#1
Hi all

I am trying to combine two variables into a new variable using DO IF ELSE IF
I keep getting an error code - what am I doing wrong!
I added new_var to my variable list first set it to Numeric
This is my code
do if Var_1 = 1 & Var_2 = 0.
Compute new_var =1.
ELSE if Var_1 = 2
Compute new_var=0.
end if.

Apologises for such a basic question
 

WJU

New Member
#3
I did read that one , quite a few others too, seems I still got it wrong!

error code
>Error # 4070. Command name: end if
>The command does not follow an unclosed DO IF command. Maybe the DO IF
>command was not recognized because of an error. Use the level-of-control
>shown to the left of the SPSS Statistics commands to determine the range of
>LOOPs and DO IFs.
>Execution of this command stops.
 

WJU

New Member
#5
Yes I did use them initially but error code was the same , should they be somewhere else
do if (Var_1 = 1 & Var_2 = 0).
Compute new_var =1.
ELSE if Var_1 = 2
Compute new_var=0.
end if.
Thank you for trying to help