1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Is there any way to do the following in SPSS?

I have a set of 12 stimulus materials that I have to give to each of my subjects in random order (I have 60 subjects). In order to randomize the stimuls materials, I wanted to have SPSS generate a variable that could shuffle the numbers 1-12 in random order, i.e., sample WITHOUT
replacement. If the randomization could be done with replacement, it would be no problem, it would simply be a matter of using the uniform distribution:

COMPUTE X= TRUNC(RV.UNIFORM(1,13)).

Is there anyway to sample WITHOUT replacement?

Sylvia
*****************************************************.

*Sylvia, Rich and SPSSX-Listers,
*The following solves the permutation problem concisely. 
*It illustrates some general SPSS approaches for. 
1: turning one case into multiple cases
2: Generating random permutations
3: turning multiple cases into one case
4: Preserving ones mouse, keyboard...sanity ;-),
(These issues arise frequently).

*Regards, David Marso
*SPSS Consulting Services
-----------------------------------------
* Here are the stimuli *.
DATA LIST / STIM01 TO STIM13 1-13 (A).
BEGIN DATA
ABCDEFGHIJKLM
END DATA.

* Create 100 copies (one per subject) *.
VECTOR STIM=STIM01 TO STIM13.
STRING STIMX(A1).
LOOP ID=1 TO 100.
+ LOOP STIMNUM=1 TO 13.
+ COMPUTE STIMX=STIM(STIMNUM).
+ XSAVE OUTFILE 'TMP' / KEEP ID STIMX.
+ END LOOP.
END LOOP.
EXE.
GET FILE 'TMP'.

* Permute the stimuli * .
COMPUTE JUMBLE=UNIFORM(1).
SORT CASES BY ID JUMBLE.
RANK VARIABLES= JUMBLE BY ID .

* Get the stimuli onto one line per subject *.
STRING STIM01 TO STIM13 (A1).
VECTOR STIM = STIM01 TO STIM13.
COMPUTE STIM(RJUMBLE)=STIMX.
AGGREGATE OUTFILE * 
/ BREAK ID 
/ STIM01 TO STIM13 = MAX(STIM01 TO STIM13).