Another vector application in SPSS
Updated: Sep 13, 2018
In a similar vein to the ‘Using vectors to deal with multi-coded questions in SPSS’ blog piece, here we’ll use use vectors and loops to create a set of calculated variables from sets of existing variables.
Suppose our final satisfaction score, satfinal, was the weighted sum of two stated measures of satisfaction, sat_a and sat_b, as given by the formula satfinal = (2 x sat_a) + (3 x sat_b). Suppose further that each respondent had answered the satisfaction questions for varying subsets of a set of five different brands.
The data was exported in the following manner, where s_a_1 is sat_a for brand 1, s_b_1 is sat_b for brand 1, s_a_2 is sat_a for brand 2, s_b_2 is sat_b for brand 2 etc., as in the table below.
We need to turn it into the following, where sfin_1 was satfinal for brand1, sfin_2 was satfinal for brand2 etc.
To accomplish this, we used the following piece of code using vectors and scratch variables.
vector #t= s_a_1 to s_b_5 .
loop #i=1 to 5.
Author: Paul Brown, Director