View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Dana DeLouis Dana DeLouis is offline
external usenet poster
 
Posts: 947
Default median of combinations from values in a column

Just curious. Can SPSS read in that many records at once?

=COMBIN(66,7) = 778,789,440

Here is just an idea. I don't know if it is of any use though.
If you are generating "Subsets" of size 4 in lexicographical order (ie
sorted) and use 4 variables a,b,c,&d,
then the mean is (a+b+c+d)/4
and the median is (b+c)/2

You execute division 1,557,578,880 times, and store real numbers in your
file.
Another idea might be to store integer values. ie just store (a+b+c+d) and
(b+c) in the text file, and see if SPSS can divide your final answers by 4
and 2.

This is not quite the code I use for Subsets, but here is a general idea for
outputting to a text file.
This is a simple idea that I'm sure you could modify.
Given a set 1-6, this generates "Subsets" of size 4.
However, this does "NOT" divide the sums by 4 and 2.
The "Mean" and "Median" go to different files.

Sub Demo()
Dim a As Long
Dim b As Long
Dim c As Long
Dim d As Long

Dim n As Long
Dim z As Long

Dim FileMean
Dim FileMedian

n = 6
z = n + 1

ChDir "C:\Temp"
FileMean = FreeFile
Open "Mean" For Output As #FileMean

FileMedian = FreeFile
Open "Median" For Output As #FileMedian

For a = 0 + 1 To n - 3
For b = a + 1 To n - 2
For c = b + 1 To n - 1
For d = c + 1 To n

Write #FileMean, a + b + c + d '(/4 if you wish)
Write #FileMedian, b + c '(/2 if you wish)

Next d, c, b, a
Close
End Sub

--
HTH :)
Dana DeLouis


wrote in message
...
In addition, is it possible to show *only* the median? This would make
it easier in terms of importing to SPSS later.

Andreas