```Date: Fri, 23 Sep 2011 12:35:12 -0700 Reply-To: Bruce Weaver Sender: "SPSSX(r) Discussion" From: Bruce Weaver Subject: Re: Sort values stored in different variables In-Reply-To: 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. http://www.spsstools.net/Syntax/RankingLargestValSortingGrouping/SortingValuesWithinCases_Bubble-Sort.txt 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 . exe . HTH. Luigi Neri wrote: > > Hi group, > > I would like to know how to sort values stored in different variables in > SPSS. > I try to make myself clearer : > > Suppose I have the following variables : A, B, C, D, E and I have n > records > > 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 > row > 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 > ai > 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 > the > internet but I cannot understand the syntax. Could you please help me ? > > Many thanks > > Luigi > ----- -- Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "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 SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ```

Back to: Top of message | Previous page | Main SPSSX-L page