I have tried to use the "compute if" function in SPSS to create a new variable from two other variables with multiple categories but to no avail even after following format here. I keep getting the error message: "Incorrect variable name: either the name is more than 64 characters, or it is not defined by a previous command".
The following are my command lines:
DO IF V1051 = 2 AND V102 = 1.
COMPUTE MITY = 0.
ELSE IF V1051 = 2 AND V102 = 2.
COMPUTE MITY = 1.
ELSE IF V1051 = 1 AND V102 = 1.
COMPUTE MITY = 2.
ELSE IF V1051 = 1 AND V102 = 2.
COMPUTE MITY = 3.
ELSE IF V1051 = 0 AND V102 = 1.
COMPUTE MITY = 4.
ELSE.
COMPUTE MITY = 5.
------------------------------
Ebenezer Nikoi
------------------------------
Original Message:
Sent: Tue June 08, 2021 12:01 PM
From: Community Support Admin
Subject: Compute Variable IF...
You could pretty much just use what you wrote, but a slightly more readable way would be
DO IF VAR1 <= 2 AND VAR2 >= 3.
COMPUTE L2SES = 1.
ELSE IF VAR1 >=3 AND VAR2 <=2.
COMPUTE L2SES = 3.
ELSE.
COMPUTE L2SES = 2.
If you have any missing values, however, in the input variables, you should test for that first as none of the branches written this way will be executed.
#SPSSStatistics
#Support
#SupportMigration