I'm new in SPSS program but I've tried to search a solution to my problem. The idea is find a way to loop through some variable names (or I think so). I want to create the variables P216_XX, P217_XX, T211_XX and OCUPAC_XX, with other variables like some inputs (P216_13, P216_12, P216_11, P216_10, P217_13, P217_12, P217_11, P217_10, T211_13, T211_12, T211_11, T211_10, OCUPAC_13, OCUPAC_12, OCUPAC_11, OCUPAC_10 and IIIDDDEEE).
I'm following the next tedious instruction:
******TEDIOUS INSTRUCTION:
*****P216_XX.
IF (IIIDDDEEE=1) P216_XX=P216_13.
EXECUTE.
IF (IIIDDDEEE=2) P216_XX=P216_12.
EXECUTE.
IF (IIIDDDEEE=3) P216_XX=P216_11.
EXECUTE.
IF (IIIDDDEEE=4) P216_XX=P216_10.
EXECUTE.
*****P217_XX.
IF (IIIDDDEEE=1) P217_XX=P217_13.
EXECUTE.
IF (IIIDDDEEE=2) P217_XX=P217_12.
EXECUTE.
IF (IIIDDDEEE=3) P217_XX=P217_11.
EXECUTE.
IF (IIIDDDEEE=4) P217_XX=P217_10.
EXECUTE.
*****T211_XX.
IF (IIIDDDEEE=1) T211_XX=T211_13.
EXECUTE.
IF (IIIDDDEEE=2) T211_XX=T211_12.
EXECUTE.
IF (IIIDDDEEE=3) T211_XX=T211_11.
EXECUTE.
IF (IIIDDDEEE=4) T211_XX=T211_10.
EXECUTE.
*****OCUPAC_XX.
IF (IIIDDDEEE=1) OCUPAC_XX=OCUPAC_13.
EXECUTE.
IF (IIIDDDEEE=2) OCUPAC_XX=OCUPAC_12.
EXECUTE.
IF (IIIDDDEEE=3) OCUPAC_XX=OCUPAC_11.
EXECUTE.
IF (IIIDDDEEE=4) OCUPAC_XX=OCUPAC_10.
EXECUTE.
In stata, the form would reduce the previous syntax with something like that:
foreach x in P216 P217 T211 OCUPAC {
replace `x'_XX=`x'_13 if IIIDDDEEE==1
replace `x'_XX=`x'_12 if IIIDDDEEE==2
replace `x'_XX=`x'_11 if IIIDDDEEE==3
replace `x'_XX=`x'_10 if IIIDDDEEE==4
}
*
In SPSS, I proved with vector, but SPSS don't accept me root in the vector, only variables. I don't know how to continue and I haven't found something similar yet
Is possible found a solution with native SPSS language? (I forgot to comment that in my work, the "administrator" doesn't allow us to install other programs like Python). What would be a possible solution?