1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
* Rename variables: recode var1 in varx, etc (names of new variables are defined automatically).

*Note that none of your initial variable's name can end with an 'x'.
* rlevesque@videotron.ca.

DATA LIST FREE /abc, sal, age, sex1, school,v1234567.
BEGIN DATA
85 95 5 87 100 1
END DATA.
LIST.
SAVE OUTFILE='c:\\temp\\mydata.sav'.
* suppose we want to recode the above variables into variables having the same name but with the last letter being replaced by x.

FLIP.
STRING newname(A8).
COMPUTE newname=CONCAT(SUBSTR(case_lbl,1,LENGTH(RTRIM(case_lbl))-1),"X").
WRITE OUTFILE 'c:\\temp\\temp.sps' 
   /"RECODE "case_lbl" (1 THRU 87.9=1) (89 THRU 98.1=1) (ELSE=COPY) INTO "newname"."/"FREQ "newname".".
EXE.

GET FILE='c:\\temp\\mydata.sav'.
INCLUDE 'c:\\temp\\temp.sps'.