DO IF SYNTAX

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

roijacobson
Posts: 1
Joined: Sun Dec 21, 2014 6:16 pm

DO IF SYNTAX

Postby roijacobson » Sun Dec 21, 2014 6:23 pm

hi all,

i've been trying to use the DO IF commnd after I read that it is ok you use IF syntax within it.
my syntax goes as follows:

DO IF (sex=2).

DATASET ACTIVATE DataSet1.
IF (Prc_Sex = 1) Why_horny=MM1_1.
IF (Prc_Sex = 2) Why_horny=MF1_1.
EXECUTE.

DATASET ACTIVATE DataSet1.
IF (Prc_Sex = 1) Why_rub_touch=MM1_2.
IF (Prc_Sex = 2) Why_rub_touch=MF1_2.
EXECUTE.

ELSE IF (sex=1)

DATASET ACTIVATE DataSet1.
IF (Prc_Sex = 1) Why_after_mastur=MM1_4.
IF (Prc_Sex = 2) Why_after_mastur=MF1_4.
EXECUTE.

DATASET ACTIVATE DataSet1.
IF (Prc_Sex = 1) Why_watching_**CENSORED**=MM1_5.
IF (Prc_Sex = 2) Why_watching_**CENSORED**=MF1_5.
EXECUTE.

END IF.

how ever, i keep getting the following error:
2776 ELSE IF The ELSE IF 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.

does anybody know why?
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

Re: DO IF SYNTAX

Postby GerineL » Mon Dec 22, 2014 11:53 am

Not entirely sure, but I think it is because of the execute commands. Spss stops there. Try putting it at the end of your if statement.

Who is online

Users browsing this forum: No registered users and 1 guest

cron