ranking syntax

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

ranking syntax

Handel, Richard W.

Hi All,

 

I am looking for a little syntax help.  

 

Here is what I would like to do:

 

1)      Take 10 variables (x1 to x10) that have integer values between 30 and 100.

2)      Create syntax that rank orders these variables and writes them out to a second set of variables based on rank order (in ascending order).  In other words, the second set of variables would indicate the relative standing of each case (X1 to X10).  (Let’s say the second set of variables is named X1a to X10a.)  

 

So, it would end up like this (I will limit it to 3 variables for this example):

 

Input data:

X1 = 50 

X2 = 70

X3 = 55

 

New Variable:

 

X1a = 1

X2a = 3

X3a = 2.

 

 

The more complicated issue is that a tie needs to be assigned a mid-point value.  So, if

 

Input data:

 

X1 = 50

X2 = 50

X3 = 70

 

Then,

X1a = 1.5

X2a = 1.5

X3a = 3

 

(That is, X3 is still the third highest score.)

 

Any ideas? 

 

Thanks,

Rick

 

 

Richard W. Handel, Ph.D.

Associate Professor

Department of Psychiatry and Behavioral Sciences

Eastern Virginia Medical School

825 Fairfax Avenue, Hofheimer Hall

Norfolk, VA 23507

Phone (757)-446-7992

 

Reply | Threaded
Open this post in threaded view
|

Re: ranking syntax

Handel, Richard W.

Disregard!  I figured it out.  Thanks!!!!!

 

Rick

 

 

 

Richard W. Handel, Ph.D.

Associate Professor

Department of Psychiatry and Behavioral Sciences

Eastern Virginia Medical School

825 Fairfax Avenue, Hofheimer Hall

Norfolk, VA 23507

Phone (757)-446-7992

 


From: Handel, Richard W.
Sent: Friday, June 12, 2009 12:35 PM
To: [hidden email]
Subject: ranking syntax

 

Hi All,

 

I am looking for a little syntax help.  

 

Here is what I would like to do:

 

1)      Take 10 variables (x1 to x10) that have integer values between 30 and 100.

2)      Create syntax that rank orders these variables and writes them out to a second set of variables based on rank order (in ascending order).  In other words, the second set of variables would indicate the relative standing of each case (X1 to X10).  (Let’s say the second set of variables is named X1a to X10a.)  

 

So, it would end up like this (I will limit it to 3 variables for this example):

 

Input data:

X1 = 50 

X2 = 70

X3 = 55

 

New Variable:

 

X1a = 1

X2a = 3

X3a = 2.

 

 

The more complicated issue is that a tie needs to be assigned a mid-point value.  So, if

 

Input data:

 

X1 = 50

X2 = 50

X3 = 70

 

Then,

X1a = 1.5

X2a = 1.5

X3a = 3

 

(That is, X3 is still the third highest score.)

 

Any ideas? 

 

Thanks,

Rick

 

 

Richard W. Handel, Ph.D.

Associate Professor

Department of Psychiatry and Behavioral Sciences

Eastern Virginia Medical School

825 Fairfax Avenue, Hofheimer Hall

Norfolk, VA 23507

Phone (757)-446-7992

 

Reply | Threaded
Open this post in threaded view
|

Re: ranking syntax

Maguin, Eugene
In reply to this post by Handel, Richard W.
Richard,

A realy simple way to do this, provided you don't have too many cases, and
even then, I'd guess, it could be done in stages, is use the Flip command to
flip the dataset so that variables are now rows and subjects are now columns
(and, thus, variables). Next, use the Rank command to rank the variables.
Finally, use the Flip command again to restore the dataset to its original
structure. I haven't done this in a long time but I'll bet others have and
can comment. Try this out and see if it will work for you. Post back and let
us know.

The alternative is to write syntax to do a within cases sort and while that
is not too hard, accounting for ties and for missing data makes the code
complex.

Gene Maguin



>>1) Take 10 variables (x1 to x10) that have integer values between 30 and
100.
2) Create syntax that rank orders these variables and writes them out to a
second set of variables based on rank order (in ascending order).  In other
words, the second set of variables would indicate the relative standing of
each case (X1 to X10).  (Let's say the second set of variables is named X1a
to X10a.)

 So, it would end up like this (I will limit it to 3 variables for this
example):

Input data:
X1 = 50
X2 = 70
X3 = 55

New Variable:
X1a = 1
X2a = 3
X3a = 2.

The more complicated issue is that a tie needs to be assigned a mid-point
value.  So, if

Input data:
X1 = 50
X2 = 50
X3 = 70

Then,
X1a = 1.5
X2a = 1.5
X3a = 3

(That is, X3 is still the third highest score.)

=====================
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: ranking syntax

Handel, Richard W.
Gene,

Thanks.  I found syntax on raynald's site that ranks within cases.  It
was easy to modify it to do what I want.  Thanks again.

Rick


Richard W. Handel, Ph.D.
Associate Professor
Department of Psychiatry and Behavioral Sciences
Eastern Virginia Medical School
825 Fairfax Avenue, Hofheimer Hall
Norfolk, VA 23507
Phone (757)-446-7992


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Gene Maguin
Sent: Friday, June 12, 2009 1:31 PM
To: [hidden email]
Subject: Re: ranking syntax

Richard,

A realy simple way to do this, provided you don't have too many cases,
and
even then, I'd guess, it could be done in stages, is use the Flip
command to
flip the dataset so that variables are now rows and subjects are now
columns
(and, thus, variables). Next, use the Rank command to rank the
variables.
Finally, use the Flip command again to restore the dataset to its
original
structure. I haven't done this in a long time but I'll bet others have
and
can comment. Try this out and see if it will work for you. Post back and
let
us know.

The alternative is to write syntax to do a within cases sort and while
that
is not too hard, accounting for ties and for missing data makes the code
complex.

Gene Maguin



>>1) Take 10 variables (x1 to x10) that have integer values between 30
and
100.
2) Create syntax that rank orders these variables and writes them out to
a
second set of variables based on rank order (in ascending order).  In
other
words, the second set of variables would indicate the relative standing
of
each case (X1 to X10).  (Let's say the second set of variables is named
X1a
to X10a.)

 So, it would end up like this (I will limit it to 3 variables for this
example):

Input data:
X1 = 50
X2 = 70
X3 = 55

New Variable:
X1a = 1
X2a = 3
X3a = 2.

The more complicated issue is that a tie needs to be assigned a
mid-point
value.  So, if

Input data:
X1 = 50
X2 = 50
X3 = 70

Then,
X1a = 1.5
X2a = 1.5
X3a = 3

(That is, X3 is still the third highest score.)

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