Why bother with Python for something which can be so trivially achieved with plain old SPSS with minimal code (4 lines, 2 actually which do any work).
You might wish to be more specific by what you mean by "combinations".
In this case it seems *OBVIOUS* that you are referring to a matrix product X'X.
Here is plain old legacy or whatever you want to call it SPSS code using the MATRIX facility.
data list list /t (A2) a1 a2 a3 a4 a5 (5F1).
BEGIN DATA.
t1 0 0 1 0 1
t2 0 0 1 0 0
t3 0 1 1 0 1
t4 0 0 0 1 1
END DATA.
LIST.
MATRIX.
GET X / VARIABLES a1 TO A5.
PRINT X.
COMPUTE XTX=T(X)*X.
PRINT XTX.
SAVE XTX / OUTFILE * .
END MATRIX.
LIST.
*Alternatively without any extras.
data list list /t (A2) a1 a2 a3 a4 a5 (5F1).
BEGIN DATA.
t1 0 0 1 0 1
t2 0 0 1 0 0
t3 0 1 1 0 1
t4 0 0 0 1 1
END DATA.
MATRIX.
GET X / VARIABLES a1 TO A5.
SAVE (T(X)*X) / OUTFILE * .
END MATRIX.
LIST.
--
HTH, David
Nath wrote
Hello,
I am looking out for a certain solution in SPSS python where i can retrieve the output in matrix format.
Below is an example :
Variables considered are a1,a2,a3,a4,a5 ( these are being accessed in different timings say t1, t2,t3,t4)
a1 a2 a3 a4 a5
t1 0 0 1 0 1
t2 0 0 1 0 0
t3 0 1 1 0 1
t4 0 0 0 1 1
My output should be a combination of all the variables that is a1,a2,a3......
The output should be a matrix as shown below:
a1 a2 a3 a4 a5
a1 0 0 0 0 0
a2 0 1 1 0 1
a3 0 1 3 0 2
a4 0 0 0 1 1
a5 0 1 2 1 3
I am trying to write a python program as i heard that this task is easily accomplished in python. Can I get your help on this ?
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?"