SPSS allows one to compute the mean across variables (where the number
of variables, N, may vary from case to case):
Compute mean.a = mean (var.a1, var.a2, var.a3..., var.aN).
I wish SPSS would similarly allow the following:
Compute median.a = median (var.a1, var.a2, var.a3..., var.aN).
Compute median.b = median (var.b1, var.b2, var.b3..., var.bN).
... So that one could use the newly computed variables in further
computations:
Compute ab.diff = median.a - median.b.
Unfortunately, I can see no way to do this in SPSS.
Any suggestions?
Here's one way: Restructure the file from WIDE to LONG
using VARSTOCASES; then use AGGREGATE to compute the desired
median(s). I have a syntax file somewhere that does this,
but can't find it right now.
Cheers,
Bruce
--
Bruce Weaver
wea...@mcmaster.ca
www.angelfire.com/wv/bwhomedir/
> Any suggestions?
One way to do this is a bit tedious, but pretty fast:
1) Put the values of the variables in a vector and sort
the vector within each case. See my code snippet for sorting
variables within cases at Raynald's site. (It's a long URL, so
just go to http://pages.infinit.net/rlevesqu/ and search on
"bubble" to get a link to the bubble-sort syntax.)
While sorting, you also would want to stick the missing values at the
end (or beginning) of the vector, and count the number of valid (non-
missing) values within the vector.
2) Find the median as the "middle" value among the nonmissing values
in the vector.
--
=-=-=-=-=-=-=-=-=-==-=-=-=
Mike Lacy, Ft Collins CO 80523
Clean out the 'junk' to email me.
Thank you in advance for teaching this to me!
Thank you in advance for showing me how to do this!
I've sent you an example via e-mail that you should be able
to adapt to fit your data.
OK, I looked into the VECTOR command and see why you suggested I use
that. Unfortunately, the variables I am actually doing this on don't
actually have the names I listed in my example (I was just using a
shorthand). Here is what I want to do, using the actual variable names
(which are measures of activity in sub-areas within each of the main
lobes of the brain):
Compute Temp.2
= median (L.sup.T, R.sup.T, L.mid.T, R.mid.T, [etc. more vars]).
Compute Front.2
= median (L.dlat.F, R.dlat.F, L.orb.F, L.orb.F, [etc. more vars]).
[I want to computer about 35 such medians, but SPSS does not
include MEDIAN under the COMPUTE command. (yet?)]
I need these new variables available in my data file, to use in
computations, such as:
Compute T_F.dif = Temp.m - Front.m.
Do you know of some way to do this? If so, I would greatly appreciate it.
Regards,
John Poole
UC San Francisco