* GlobalAutorecode.sps *. *(Q). I have data such as the following. ID STR1 STR2 STR3 STR4 STRX 1 a b c d e 2 b d e 3 c c a c b 3 e c a 2 e b a 1 a b and would like to use all of these string variables to do one autorecode, let's say something like an autorecode overall. No variable has all strings, but all variables together have all strings which can appear. What I need is one dictionary for all of my variables. Do you know an easy way to do this? So that I get this result: ID STR1 STR2 STR3 STR4 STRX 1 1 2 3 4 5 2 2 4 5 3 3 3 1 3 2 3 5 3 1 2 5 2 1 1 1 2 "a"=1, "b"=2, "c"=3, "d"=4, "e"=5 *(A) By Raymald Levesque 2002/07/16. DATA LIST LIST /id (F1.0) str1 str2 str3 str4 str5 (5A1). BEGIN DATA 1 a b c d e 2 b d e 3 c c a c b 4 e c a 5 e b a 6 a b END DATA. LIST. *////////////////. DEFINE !apply (stem=!TOKENS(1) /nb=!TOKENS(1)) SAVE OUTFILE='c:\\temp\\original data.sav'. STRING s(A1). VECTOR s=!CONCAT(!stem,'1') TO !CONCAT(!stem,!nb). LOOP cnt=1 TO !nb. COMPUTE s=s(cnt). XSAVE OUTFILE='c:\\temp\\data1.sav' /KEEP=id cnt s. END LOOP. EXECUTE. GET FILE='c:\\temp\\data1.sav'. SELECT IF RTRIM(s)<>"". AUTORECODE s /INTO srec. N OF CASES 1. SAVE OUTFILE='c:\\temp\\label definitions.sav'. GET FILE='c:\\temp\\data1.sav'. SELECT IF RTRIM(s)<>"". SORT CASES BY s. AGGREGATE /OUTFILE=* /BREAK=s /id = N(id). COMPUTE recnb=$CASENUM. SAVE OUTFILE='c:\\temp\\data2.sav'. GET FILE='c:\\temp\\data1.sav'. SORT CASES BY s. MATCH FILES FILE=* /TABLE='c:\\temp\\data2.sav' /BY=s. SORT CASES BY id cnt. VECTOR str(!nb F1). COMPUTE str(cnt)=recnb. AGGREGATE /OUTFILE=* /BREAK=id /!CONCAT(!stem,'1') TO !CONCAT(!stem,!nb) = FIRST(!CONCAT(!stem,'1') TO !CONCAT(!stem,!nb)). !DO !cnt=1 !TO !nb RENAME VARIABLE (!CONCAT(!stem,!cnt)=srec). APPLY DICTIONARY FROM='c:\\temp\\label definitions.sav'. RENAME VARIABLE (srec=!CONCAT(!stem,!cnt)). !DOEND !ENDDEFINE. *////////////////. SET MPRINT=yes. !apply stem=str nb=5. SET MPRINT=no.