Firstly, RECODE
command can take in (and output) multiple variables. See the documentation and the example provide here. Though the first example provides in that link recodes into the same variables, an equivalent command to recode into different variables would be:
RECODE V1 TO V3 (0=1) (1=0) (2,3=-1) (9=9) (ELSE=SYSMIS) INTO W1 to W3.
The above works because it is intutive for SPSS to interpret and expand out W1 TO W3
to equal W1, W2, W3
.
The difficulty you have, although SPSS can read sequential variables cqC2_1_11 TO cqC2_21_415
as they are input existing variables in the dataset, it is not easy to specify equivalent matching output variable names.
For example, you could not simply specify RECODE....INTO T3B_cqC2_1_11 TO T3B_cqC2_21_415
as you have double indexing occurring and SPSS would not know exactly how to expand out those names.
If however, for example you had cqC2_1 TO cqC2_415
i.e. 415 variables you could use RECODE....INTO T3B_cqC2_1 TO T3B_cqC2_415
.
So your best option is to build a custom macro, using either SPSSs build in macro facility or its integrated python programmability.
Python programmability is far superior so below is python solution you can adapt for your specific needs and criteria, to help you get started:
get file="C:\Program Files\IBM\SPSS\Statistics\23\Samples\English\Employee data.sav".
begin program.
import spss, spssaux, spssdata
spss.Submit("set mprint on.")
vd=spssaux.VariableDict(pattern="job")
spss.Submit("""RECODE %s (8 THRU HI=1) (ELSE=COPY) INTO %s.""" % ("\n".join([str(v) for v in vd]),"\n".join(["T3B_" + str(v) for v in vd])))
for v in vd:
spss.Submit("""VARIABLE LABEL T3B_%s "%s".""" %(v, "T3B_" + v.VariableLabel))
spss.Submit("set mprint off.")
end program.