# How to compute a new variable that is defined by two categorical variables using SPSS?

I have a questionnaire with a part (a) and part (b). It looks like this:

(a) "Do you ever feel sad":
0="never", 1="sometime", 2="often", 3="nearly always"
(b) "How distressed are you by this":
0="not distressed", 1="a bit distressed", 2="quite distressed",
3="very distressed".


I want to create a new variable:

"Do you feel sad?"
Response: 0="no", but 1="Yes, but no distress", 3="Yes and its distressing".


How can I create this new variable using SPSS?

-
I voted to close as off topic. There's no statistical question here. –  Macro Apr 27 '12 at 16:41

You would have to use logical operators and conditionals.

part a: 0 1 2 3
part b: 0 1 2 3

Composite:

0 = (a0)
1 = ~(a0) & (b0)
3 = ~(a0) & ~(b0)


I haven't tested this, but the SPSS code for computing the composite scores with the outcome 1 would be something like this:

DO IF ( (A ~= 0) & (B = 0)).
RECODE A (0=1) INTO C.
END IF.
VARIABLE LABELS C 'Composite'.
EXECUTE.

-
The question addresses coding and data management. Faulty coding (e.g. 1 2 rather than 0 1) can result in poor statistical models for NHST in regression and is of statistical relevance IMHO. –  noumenal Apr 27 '12 at 16:48
Daniel thanks for the help, although Im not entirely sure how to implement it. Ill have a go later this evening. –  Rave Apr 27 '12 at 18:08
Use the menu command: Transform/Recode into different variables.... You would have to use this command three times. –  noumenal Apr 27 '12 at 22:37
I've had a think about this. On the composite variable for level 1: Frequency of experience (1="sometime", 2="often", 3="nearly always") + Distress (0="no") Surely if No is scored as 0 there is no real need to add it since its inclusion to the frequency items will add no information? So can I recode it as follows? 0 = No 1 = Frequency items (1,2,3) = Yes but not distressing 2= Yes it is distressing (distress items 1,2,3) since anything over 0 = distress on that scale? I hope this make sense :/ –  Rave Apr 27 '12 at 22:56
Daniel, have a look, ive done it using this syntax. Thx god! Apologies, I have no idea how to use the code syntax for this site. IF (cape1 = 0) cape_1 = 0. IF (cape1 >= 1 and cape1b = 0) cape_1=1. IF (cape1 >= 1 and cape1b >= 1 ) cape_1=2. EXECUTE. –  Rave Apr 30 '12 at 16:11