arrays

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

arrays

Bruce Colton
I have a need for a 2-dimensional array.  Ex.  My cases are by the hour, with 1500 nodes (variables) per case.  For each group of 24 cases (24 hours or 1 day), I would like to bring this data into an array such as:  nodes(24,1500).  I know SPSS has the VECTOR command, to give me a 1-dimensional array, however, I could really use a 2-dim array.  Any ideas/suggestions are greatly appreciated.  Thanks!

=====================
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: arrays

Peck, Jon
The question is what do you want to do with the array?

The MATRIX procedure provides two-dimensional arrays and can read and write SPSS data files.  It cannot call other procedures, however.

If you need to go beyond that, programmability offers extensive support for arrays.  Besides the built-in array support in the languages (Python and, in 16, R), there are extensive libraries available for matrix operations and other similar things.  Numpy, in particular, is worth looking at for Python.

HTH,
Jon Peck

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bruce Colton
Sent: Tuesday, July 01, 2008 7:58 AM
To: [hidden email]
Subject: [SPSSX-L] arrays

I have a need for a 2-dimensional array.  Ex.  My cases are by the hour, with 1500 nodes (variables) per case.  For each group of 24 cases (24 hours or 1 day), I would like to bring this data into an array such as:  nodes(24,1500).  I know SPSS has the VECTOR command, to give me a 1-dimensional array, however, I could really use a 2-dim array.  Any ideas/suggestions are greatly appreciated.  Thanks!

=====================
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

=====================
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: arrays

Richard Ristow
In reply to this post by Bruce Colton
At 09:57 AM 7/1/2008, Bruce Colton wrote:

>I have a need for a 2-dimensional array.  Ex.  My cases are by the
>hour, with 1500 nodes (variables) per case.  For each group of 24
>cases (24 hours or 1 day), I would like to bring this data into an
>array such as:  nodes(24,1500).  I know SPSS has the VECTOR command,
>to give me a 1-dimensional array, however, I could really use a
>2-dim array.  Any ideas/suggestions are greatly appreciated.

The short answer is, no, SPSS has no such capability, directly.

It is always possible to simulate a multi-dimensional array in a
one-dimensional array -- that's how multi-dimensional arrays are
implemented. If you have vector 'nodes' with 24*1500 elements, and
want to index by (hour,node), then the index into the one-dimensional
'nodes' becomes (node+1500*(hour-1)), to store all 'node' values for
the same hour together; or (hour+24*(node-1)), if you store all 24
hour-values of the same node together. You could write a macro
!node(hour,node#) that would perform this index arithmetic and index
into the big one-dimensional array.

But (and many readers have been waiting for me to say this), is this
the best way to represent your data? Generally, SPSS works more
gracefully with more cases and fewer variables -- with what's called
'long' data organization. 1,500 variables is a lot; 36,000 (24*1500)
is very many. I would certainly think about 24 records, each with the
1,500 node values for one hour; perhaps, your node values group in
ways that would suggest multiple records within an hour, and fewer
variables yet.

I'm writing blind, not knowing what you need to do with your data.
But in SPSS, I'd look very hard at a 'longer' organization, to take
advantage of SPSS's facility in looping through many cases.

=====================
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