17. Trivia: What is the most complicated data manipulation you can perform in the fewest statements? (The FLIP command comes to mind). Know any other SPSS trivia? I have answered recently a question like that in the list, and I solved it using MATRIX and 19 lines of code: * (Q) I have a data set of 10 variables where each vector represents * the ranking of those concepts by one individual. To be specific * the data looks like this: * * ID v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 * 1 2 3 7 8 10 1 4 5 6 9 * 2 10 2 1 3 4 5 6 7 9 8 * 3 9 6 4 2 1 3 5 7 10 8 * . . . . . . . . . . . * . . . . . . . . . . . * . . . . . . . . . . . * . . . . . . . . . . . * 1000 2 4 8 10 9 3 5 7 1 6 * * I want to change this data into a matrix where everything in columns * above the diagonal is the number of times each concept was ranked higher * than the corresponding row concept and everything in columns below the * diagonal is the number of times each concept was ranked lower than the * row concept. The diagonals themselves will be equal to N/2. * (A) Using the presented part of the dataset (only 4 rows) *. DATA LIST LIST/id v1 TO v10 (11 F8.0). BEGIN DATA 1 2 3 7 8 10 1 4 5 6 9 2 10 2 1 3 4 5 6 7 9 8 3 9 6 4 2 1 3 5 7 10 8 1000 2 4 8 10 9 3 5 7 1 6 END DATA. * The solution *. MATRIX. GET data /VAR=v1 TO v10 /NAMES=vnames. COMPUTE nvars=NCOL(data). COMPUTE ndata=NROW(data). COMPUTE diagmat=MAKE(nvars,nvars,0). CALL SETDIAG(diagmat,ndata/2). LOOP i=1 TO ndata. - LOOP j=1 TO nvars-1. - LOOP k=j TO nvars. - DO IF data(i,j) GT data(i,k). - COMPUTE diagmat(j,k)=diagmat(j,k)+1. - ELSE IF data(i,j) LT data(i,k). - COMPUTE diagmat(k,j)=diagmat(k,j)+1. - END IF. - END LOOP. - END LOOP. END LOOP. SAVE diagmat /OUTFILE='c:\temp\MATRIX.sav' /NAMES=vnames. END MATRIX. * The report *. GET FILE='C:\Temp\MATRIX.sav'. FORMAT v1 TO v10 (F8.0). LIST.