spssrecode

SPSS: How to access values of variables, where the names of the variables I want are the values of another variable


In SPSS, I have a variable, CumulLast, which takes on values between 1 and 20. I have another family of variables, of the form Status.X, where X takes on values between 1 and 20 (e.g. Status.1, Status.2, Status.3, are all variables in my dataset). What I'm trying to do is to create a new variable, StatusLast, whose value is the value of Status.Y, where Y is the value stored in each row's CumulLast. For example, if in row 1, CumulLast is 5, I want row 1's StatusLast value to equal the value of Status.5 in row 1.

I've tried recoding CumulLast into StatusCumulLast, with values of the form Status.X (i.e. the variable names I want), but I don't know where to go from here, and if I can skip this step.


Solution

  • Ended up doing this later on:

    VECTOR vecStatus = Status.1 to Status.20.
    COMPUTE StatusLast = vecStatus(CumulLast).