First, if you want to sum a bunch of variables within a case, look at the sum function, which can also use TO. For example
compute z = sum(var1 to var5)
To use TO, the variables need to be contiguous in the file.
Second, the variables need to be numeric. If they are strings but the strings represent numbers, you can change the variable types in the Data Editor Variable View or use the ALTER TYPE command to make them numbers.
You would never use variable labels in a computation. A label is the same for all cases, so this would never make sense.
Finally, these variable names are extremely long and rather difficult to work with. I suggest that you rename to have shorter names and use the question text as the variable label.
------------------------------
Jon Peck
------------------------------
Original Message:
Sent: Fri July 23, 2021 04:30 AM
From: Alexander Farr
Subject: Compute variable: Use numeric label of a variable instead of string value
Dear community,
I am new to SPSS and would like to determine the average of 5 questionnaire items as follows:
However, this throws the following error message:
By reducing the formula, I identified that the issue is that the variables are not recognised as integers but as strings. I have added the following labels so that they look like this:
This is the data when not using the label but the original view:
Is there any possibility to use the labels (1-7) rather than the values (String like "Agree"...) to perform the calculations?
Thank you very much in advance for your help!
------------------------------
Alexander Farr
------------------------------
#SPSSStatistics