Finding Mode or ranks

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

Finding Mode or ranks

zstatman
Brain Blank!

I have 6 variables where there are ranks in each from 1 to 4 and all I want
to do is find the mode across the 6 variables - The most occurring rank and
place its code in a new variable (say "most"). If a tie then place a 9 in
"most"



WMB
Statistical Services

============
mailto: [hidden email]
http:\\home.earthlink.net\~info.statman
============

=====================
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
Will
Statistical Services
 
============
info.statman@earthlink.net
http://home.earthlink.net/~z_statman/
============
Reply | Threaded
Open this post in threaded view
|

Re: Finding Mode or ranks

Art Kendall
I am a little confused if you have ranks for the variables, wouldn't the
responses be 1 to 6 each value occurring once in the set of six, unless
there were a tie say at 3.



Open a new instance of SPSS.  Copy the syntax below to a syntax file.
Click <run>. Click <all>.
Is this what you are looking for?


data list list/ id(f2) v1 to v6 (6f3.1).
begin data
01 1 2 3 4 5 6
02 6 5 4 3 2 1
03 1.5 1.5 3 4 5 6
04 1 2.5 2.5 4 5 6
05 1 2 3.5 3.5 5 6
06 1 2 3 4.5 4.5 6
07 1 2 3 4 5.5 5.5
08 1.5 1.5 3.5 3.5 5.5 5.5
13 1.5 1.5 3 4 5.5 5.5
09 2 2 2 4 5 6
10 3.5 3.5 3.5 3.5 3.5 3.5
11 2.5 2.5 2.5 2.5 5.5 5.5
12 3 3 3 3 3 6
end data.
count k1   = v1 to v6(1).
count k1.5 = v1 to v6(1.5).
count k2   = v1 to v6(2).
count k2.5 = v1 to v6(2.5).
count k3   = v1 to v6(3).
count k3.5 = v1 to v6(3.5).
count k4   = v1 to v6(4).
count k4.5 = v1 to v6(4.5).
count k5   = v1 to v6(5).
count k5.5 = v1 to v6(5.5).
count k6   = v1 to v6(6).
compute mosthits = max(k1 to k6).
formats k1 to k6 mosthits (f1).
compute mode1 =0.
compute mode2 =0.
compute mode3 =0.
formats mode1 to mode3 (f3.1).
do if mosthits ne 1.
do repeat
   k = k1 to k6
  /v = 1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6.
do if  k eq mosthits.
do if mode1 eq 0.
compute mode1 =v.
else if mode1 gt 0 and mode2 eq 0 and  v gt mode1.
compute mode2 =v.
else if mode2 gt 0 and mode3 eq 0 and v gt mode2.
compute mode3 =v.
end if.
end if.
end repeat.
end if.
list vars= id v1 to v6 mosthits mode1 mode2 mode3.


Art Kendall
Social Research Consultants







Statmanz wrote:

> Brain Blank!
>
> I have 6 variables where there are ranks in each from 1 to 4 and all I want
> to do is find the mode across the 6 variables - The most occurring rank and
> place its code in a new variable (say "most"). If a tie then place a 9 in
> "most"
>
>
>
> WMB
> Statistical Services
>
> ============
> mailto: [hidden email]
> http:\\home.earthlink.net\~info.statman
> ============
>
> =====================
> 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
Art Kendall
Social Research Consultants