Reputation: 1237
Is it possible to nest conditional statements in SPSS?
The following did not work for me:
DO IF (t = resultcodeid)
DO IF t = 1
COMPUTE hits = r.
END IF.
DO IF t = 2
COMPUTE misses = r.
END IF.
END IF.
Upvotes: 1
Views: 5873
Reputation: 1351
#YOU CAN USE THIS PROCESS:
DO IF (t = resultcodeid)
DO IF t = 1
COMPUTE hits = r.
ELSE IF t = 2
COMPUTE misses = r.
ELSE IF T=3
COMPUTE misses=r.
ELSE IF .......
END IF.
EXECUTE.
Upvotes: 1
Reputation: 5417
DO IF can certainly be nested. Note that each statement needs to be terminated by a period.
Also, since the inner ones are alternatives, it would be cleaner to write that as
do if t = 1.
...
else if t = 2.
...
end if.
HTH, Jon Peck
Upvotes: 4