Ordinarily, for a recode on a single variable, I would RECODE MyVar ... INTO
MyNewVar and then CROSSTAB TABLES = MyVar BY MyNewVar. In order to *verify that I drafted the recode the way I intended*. However, with a multiple response set, it is more challenging to be sure the a recode works as intended. The syntax below shows one way to do this. Note the -2 category for checking if some values of the old variable are overlooked in the recode. NEW FILE. * create example set of data. DATA LIST LIST/ MyCrops (a100). BEGIN DATA 'beans|corn|apples|pears' 'apples|beans' 'pear|corn|potato' 'potatoes|apple|bean' 'blé|poire|haricots' 'potatos' 'pommes|poires' 'manzanas|frijoles|maíz' 'maíz|peras' END DATA. * split string into variable names will want in final file. spssinc trans result = T.Crop01 to T.Crop04 type=25 /formula "string.split(MyCrops, '|')". * convert into variables with names will want in final file. AUTORECODE VARIABLES = T.Crop01 to T.Crop04 /INTO Crop01 to Crop04 /BLANK = MISSING /GROUP /PRINT. * convert into variables will NOT want in final file but need . * to document recodes. AUTORECODE VARIABLES = T.Crop01 to T.Crop04 /INTO z@Crop01 to z@Crop04 /BLANK = MISSING /GROUP. MRSETS /MCGROUP NAME=$SetOfCrops LABEL='all crops in final' VARIABLES=Crop01 TO Crop04 /DISPLAY NAME=[$SetOfCrops]. MRSETS /MCGROUP NAME=$z@SetOfCrops LABEL='crops before combining' VARIABLES=z@Crop01 TO z@Crop04 /DISPLAY NAME=[$z@SetOfCrops]. RECODE Crop01 TO Crop04 (20=-1)(1,2,10,16=2)(3,4,7,8=4)(6,9=6)(11,12,13,15=12)(17,18,19=18)(ELSE=-2). ADD VALUE LABELS Crop01 TO Crop04 -1 'missing' -2 'not considered in recode'. * Custom Tables. CTABLES /VLABELS VARIABLES=$z@SetOfCrops DISPLAY=LABEL /TABLE $z@SetOfCrops [COUNT F40.0] /CATEGORIES VARIABLES=$z@SetOfCrops ORDER=A KEY=VALUE EMPTY=INCLUDE MISSING=EXCLUDE. * Custom Tables. CTABLES /VLABELS VARIABLES=$SetOfCrops DISPLAY=LABEL /TABLE $SetOfCrops [C][COUNT F40.0] /CATEGORIES VARIABLES=$SetOfCrops ORDER=A KEY=VALUE EMPTY=EXCLUDE MISSING=EXCLUDE. VARSTOCASES /ID=id /MAKE result FROM Crop01 Crop02 Crop03 Crop04 /MAKE Start FROM z@Crop01 z@Crop02 z@Crop03 z@Crop04 /INDEX=Index1(4) /KEEP= /NULL=KEEP /COUNT=crop#s "somethig". CROSSTABS TABLES = Start BY Result. ----- Art Kendall Social Research Consultants -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Art Kendall
Social Research Consultants |
Free forum by Nabble | Edit this page |