Matrix Help

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Matrix Help

Matt Freeman
I've written the syntax below and all is well except that I would like the columns of the product matrix PROD, namely Z1, Z2, and Z3, to be written in
the active data set.  When I run this code, a new data editor window opens
with Z1, Z2, and Z3.

Is there a solution that doesn't involve cutting and pasting?

Thanks, Matt


With the active data set containing the variables X1, X2, and X3...

MATRIX.
GET X / VARIABLES = X1, X2, X3.
COMPUTE U = {.65, .09, -.76; .51, .8, .33; .57, -.59, .56}.
COMPUTE PROD = X * U.
SAVE PROD / OUTFILE = * / VARIABLES = Z1, Z2, Z3.
END MATRIX.

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: Matrix Help

David Marso
Administrator
Consider MATCH FILES or something like the following:
data list free / a b c d e f.
begin data
1 2 3   2 3 4   6 5 7   6 5 4   4 3 4   4 3 3
end data.
MATRIX.
GET x / FILE * / VAR a b c/NAMES=N1.
GET data2 / FILE * / VAR d e f/NAMES=N2.
COMPUTE U = {.65, .09, -.76; .51, .8, .33; .57, -.59, .56}.
COMPUTE PROD = X * U.
COMPUTE NX={N1,N2,"Z1","Z2","Z3"}.
SAVE {x, data2 ,PROD}/ OUTFILE = * / NAMES = NX.
END MATRIX.
Matt Freeman wrote
I've written the syntax below and all is well except that I would like the columns of the product matrix PROD, namely Z1, Z2, and Z3, to be written in
the active data set.  When I run this code, a new data editor window opens
with Z1, Z2, and Z3.

Is there a solution that doesn't involve cutting and pasting?

Thanks, Matt


With the active data set containing the variables X1, X2, and X3...

MATRIX.
GET X / VARIABLES = X1, X2, X3.
COMPUTE U = {.65, .09, -.76; .51, .8, .33; .57, -.59, .56}.
COMPUTE PROD = X * U.
SAVE PROD / OUTFILE = * / VARIABLES = Z1, Z2, Z3.
END MATRIX.

=====================
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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"