1
DO IF  (WB4 = 1). 
    RECODE WB5 (0=0) (1=1) (2=2) (3=3) (4=4) (5=5) INTO WB5_1.
    IF  (WB4 = 2). 
    RECODE WB5 (0=5) (1=6) (2=7) (3=8) INTO WB5_1. 
    IF  (WB4 = 3). 
    RECODE WB5 (0=8) (1=9) (2=10) INTO WB5_1. 
    IF  (WB4 = 4). 
    RECODE WB5 (0=10) (1=11) (2=12) (3=13) (4=14) (5=15) (6=16) (7=17) INTO WB5_1. 
END IF. 
EXECUTE.

I am trying to develop a new variable using multiple options by connecting the options of two variables to create a new variable. Please guide me I have an error.

2 Answers 2

1

When you have an error, you should post the error message with your question.

In this case, though, the problem is likely the use of the IF statement instead pf DO IF IF takes only a simple statement like compute. Instead use DO IF condition.
RECODE ...
END IF.

Sign up to request clarification or add additional context in comments.

Comments

1

As pointed out by JKP, not posting the error makes it a bit difficult to fully debug your syntax.

One think I can tell you from the get go is that you are clearly miss-using the IF command: it needs to have 2 parameters:

IF [condition] [transformation].

You just have the condition, followed by the RECODE command; IF does not work that way. It can work inside a DO IF END IF structure, but you need to provide both parameters.

Alternatively, you can use an IF ELSE IF END IF structure (you would just need to add the "else"s in your current syntax:

DO IF  (WB4 = 1). 
    RECODE WB5 (0=0) (1=1) (2=2) (3=3) (4=4) (5=5) INTO WB5_1.
    ELSE IF  (WB4 = 2). 
    RECODE WB5 (0=5) (1=6) (2=7) (3=8) INTO WB5_1. 
    ELSE IF  (WB4 = 3). 
    RECODE WB5 (0=8) (1=9) (2=10) INTO WB5_1. 
    ELSE IF  (WB4 = 4). 
    RECODE WB5 (0=10) (1=11) (2=12) (3=13) (4=14) (5=15) (6=16) (7=17) INTO WB5_1. 
END IF. 
EXECUTE.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.