Home > Blockchain >  How can I make the following variable on SPSS?
How can I make the following variable on SPSS?

Time:11-06

I have a variable with values from -100 to 100. I want a new variable where -14 to 14 will be 1 and all others will be 0.

I have this so far but I get an error.

DO IF (Rad_Start_Minus_Chemo_start GT -14).
Compute         NACRT =1.
ELSE IF (Rad_Start_Minus_Chemo_start LT 14).
COMPUTE        NACRT=1
ELSE IF (Rad_Start_Minus_Chemo_start GT 14).
Compute         NACRT=0.
ELSE IF (Rad_Start_Minus_Chemo_start LT -14).
Compute         NACRT=0.
END IF.

CodePudding user response:

You may use RECODE:

RECODE Rad_Start_Minus_Chemo_start (-14 THRU 14 = 1) (ELSE = 0) /INTO NACRT.

or

COMPUTE NACRT = RANGE(Rad_Start_Minus_Chemo_start, -14,14).

(this will compute NACRT as a boolean 0/1 variabile; less flexible than recode, but in your case it gets the job done).

  • Related