Date: Fri, 23 Sep 2011 12:35:12 -0700
Reply-To: Bruce Weaver <firstname.lastname@example.org>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Bruce Weaver <email@example.com>
Subject: Re: Sort values stored in different variables
Content-Type: text/plain; charset=us-ascii
If you want a native SPSS solution, there's a bubble sort example on
Raynald's site (posted by Mike Lacy) that could be modified.
For your example, I think it would be something like:
* Sort A to E into ascending order .
vector x = A to E .
loop #i = 1 to 4 . /* top index is 1 less than number of variables
loop #j = #i+1 to 5 .
do if x(#i) GE x(#j) .
compute #temp = x(#j) .
compute x(#j) = x(#i) .
compute x(#i) = #temp .
end if .
end loop .
end loop .
Luigi Neri wrote:
> Hi group,
> I would like to know how to sort values stored in different variables in
> I try to make myself clearer :
> Suppose I have the following variables : A, B, C, D, E and I have n
> A B C D E
> 1 a1 b1 c1 d1 e1
> 2 a2 b2 c2 d2 e2
> 3 a3 b3 c3 d3 e3
> 4 a4 b4 c4 d4 e4
> 5 a5 b5 c5 d5 e5
> 1 an bn cn dn en
> I want to change the order of the values in each row. So let's consider
> ith. Suppose that this is the order :
> bi > ci > ai > ei > di
> I want to put in the variable A bi in the variable B ci in the variable C
> etc ...
> I would like to use VECTORS and LOOPS and IF to do that but I cannot
> understand how those structures work in SPSS. I looked for resources on
> internet but I cannot understand the syntax. Could you please help me ?
> Many thanks
"When all else fails, RTFM."
NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Sort-values-stored-in-different-variables-tp4834093p4834887.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
For a list of commands to manage subscriptions, send the command