|
This is my first time trying the Matrix-End Matrix procedure. People have
answered my earlier (naive?) question, so I've moved on to new problems. I want to extract the diagonal of a large distance matrix. One piece of confusion for me is the phrase 'variable reference' in the explanation of Get syntax. Is it a reference that is variable? Or does it refer to one of the variables within the data file? If so, how is this different from the variable list? ---------- GET variable reference [/FILE={file reference}] {* } [/VARIABLES = variable list] [/NAMES = names vector] <snip> ---------- My next problem is with the function 'Diag()'. Here is what I tried: MATRIX. GET MM /FILE={c:\lsay\students\DISTMTX07.sav} /VARIABLES ALL /NAMES = LSAYID. DIAG(MM). END MATRIX. I not only get several error messages about the get statement, but also get: "> Error # 12546 in column 1. Text: DIAG > MATRIX syntax error: unrecognized statement name. Is it spelled correctly? > This command not executed." I obviously don't have the Diag() syntax right. What should I have written? Where am I going wrong with the Get statement? Marian Mitchell ===================== 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 |
|
At 08:11 PM 11/7/2007, Marian Louise Mitchell wrote:
>This is my first time trying the Matrix-End Matrix procedure. People have >answered my earlier (naive?) question, so I've moved on to new problems. > >I want to extract the diagonal of a large distance matrix. Below are your questions, the answers, and a demonstration. This is SPSS 14 draft output: |-----------------------------|---------------------------| |Output Created |08-NOV-2007 00:50:43 | |-----------------------------|---------------------------| C:\Documents and Settings\Richard\My Documents \Temporary\SPSS \2007-11-07 Mitchell - confused about matrix -end matrix syntax.SAV CASEID X1 X2 X3 X4 X5 001 101 201 301 401 501 002 102 202 302 402 502 003 103 203 303 403 503 004 104 204 304 404 504 005 105 205 305 405 505 006 106 206 306 406 506 007 107 207 307 407 507 008 108 208 308 408 508 Number of cases read: 8 Number of cases listed: 8 * "One piece of confusion for me is the phrase 'variable . * reference' in the explanation of Get syntax. Is it a reference . * that is variable? Or does it refer to one of the variables . * within the data file?" . * The "variable reference" is the name of the *matrix* variable . * that will be created. Values will be read from the variables in . * the "file reference" file that are listed in "variable list": . MATRIX. GET EXES /FILE = TestData /VARIABLES = X1 TO X5 /NAMES = EXNAME. PRINT EXES /FORMAT="F4" /TITLE ="This is matrix EXES, the input:" /CNAMES=EXNAME. * "My next problem is with the function 'Diag()'. Here is what . * I tried: . * MATRIX. . * GET MM /FILE={c:\lsay\students\DISTMTX07.sav} . * /VARIABLES ALL . * /NAMES = LSAYID. . * DIAG(MM). . * END MATRIX. . * I get: . * > Error # 12546 in column 1. Text: DIAG . * > MATRIX syntax error: unrecognized statement name." . * DIAG is a function, not a statement; use it in a COMPUTE . * statement, to assign the diagonal to a matrix variable: . COMPUTE DiagEX = DIAG(EXES). PRINT DiagEX /FORMAT="F4" /TITLE ="These are the diagonal values:". END MATRIX. Matrix |-----------------------------|---------------------------| |Output Created |08-NOV-2007 00:50:43 | |-----------------------------|---------------------------| C:\Documents and Settings\Richard\My Documents \Temporary\SPSS \2007-11-07 Mitchell - confused about matrix -end matrix syntax.SAV Run MATRIX procedure: This is matrix EXES, the input: X1 X2 X3 X4 X5 101 201 301 401 501 102 202 302 402 502 103 203 303 403 503 104 204 304 404 504 105 205 305 405 505 106 206 306 406 506 107 207 307 407 507 108 208 308 408 508 These are the diagonal values: 101 202 303 404 505 ------ END MATRIX ----- =================== APPENDIX: Test data =================== * ................................................................. . * ................. Test data ..................... . FILE HANDLE TestData /NAME='C:\Documents and Settings\Richard\My Documents' + '\Temporary\SPSS\' + '2007-11-07 Mitchell - confused about matrix ' + '-end matrix syntax' + '.SAV'. NEW FILE. INPUT PROGRAM. . NUMERIC CASEID (N3). . NUMERIC X1 TO X5 (F4). . VECTOR X = X1 TO X5. . LOOP CASEID = 1 TO 8. . LOOP #IDX = 1 TO 5. . COMPUTE X(#IDX) = 100*#IDX + CASEID. . END LOOP. . END CASE. . END LOOP. END FILE. END INPUT PROGRAM. SAVE OUTFILE=TestData. ===================== 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 |
| Free forum by Nabble | Edit this page |
