Date: Sun, 30 Jul 2006 11:09:14 +0200
Reply-To: Hillel Vardi <hilel@BGU.AC.IL>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Hillel Vardi <hilel@BGU.AC.IL>
Subject: Re: Randomly Sort a variable
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Here is how to get as many random columns as you need without using any
title Randomly Sort a variable.
input program .
loop i=1 to 12 .
end case .
end loop .
end file .
end input program .
* >>>>>>>>>>>>>>>>>> change here to get as many copy as needed <<<<<<
loop i=1 to 8 .
end loop .
sort cases by i var1 .
add files file=* /first=start/by i .
if start eq 1 seq=0.
compute seq=sum(seq,1) .
sort cases by seq i .
/ID = seq
/INDEX = i
/GROUPBY = VARIABLE .
Ben Gurion U
Vishal Lala wrote:
> For a paper we are working on, I need to randomly sort data from one
> column/variable into another. So, if the data in the mother
> column/variable is 2, 7, 5, 9, 4, the data in the next column needs to be
> randomly sorted like say 4, 5, 9, 7, 2. One way to do this is to create a
> random id variable and sort based on that but the problem is that "Sort"
> will change the sequence of all cases not just the column of interest. I
> could copy and paste but this will take an inordinately long time for the
> 10,000 random columns we have planned. I would greatly appreciate any
> Dr. Vishal Lala
> Assistant Professor of Marketing
> Pace University