How to use the results of matrix computation to compute new variables in an active dataset

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

KirinGuess
Posts: 5
Joined: Sun May 15, 2016 7:57 am

How to use the results of matrix computation to compute new variables in an active dataset

Postby KirinGuess » Tue Nov 01, 2016 3:54 am

Hello everyone,

I would like to ask two questions. First, from which version does SPSS support the command MATRIX and matrix computation? By 'matrix computation', I mean doing something like this:

Code: Select all

MATRIX.
   COMPUTE A={1,2;3,4}.
   PRINT A.
   COMPUTE B=CSUM(RSUM(A)).
   PRINT B.
END MATRIX.
My second question is how to use the results of matrix computation to generate new variables in an active dataset that already contains other variables.

I tried to use the matrix command SAVE to save matrix results as new variables in the active dataset for the use of generating other new variables. However, it seems that SPSS can only save matrix results in a new SAV file, instead of appending matrix results to the active SAV as new variables, when the active SAV already contains data. Surely, I can merge the new SAV file back to the active SAV, but I am just wondering whether there is a more efficient way. More concretely, for example, if I want to use the matrix B (which is a scalar in the previous toy example) to generate a new variable named B2 in the active SAV for all of respondents (cases), how should I do? Is there any syntax like: COMPUTE B2= MATRIX(B).

Code: Select all

MATRIX.
   COMPUTE A={1,2;3,4}.
   PRINT A.
   COMPUTE B=CSUM(RSUM(A)).
   PRINT B.
END MATRIX.

COMPUTE B2= MATRIX(B).
EXECUTE.
Thank you in advance.

Kirin

Who is online

Users browsing this forum: johnnyrut and 3 guests

cron