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
* (Q) 	Suppose we have 8 variables and each one has 50 cases but
	those cases are in 5 rows of 10 columns each,
	The task is to reformat each of the 8 variables into a single
	column.
* (A) Posted to newsgroup by rlevesque on 2000/9/17.

* This section builds a sample data file which has the same structure
	as your current file. (Var 1 contains 50 1, Var2 contains 50 2, etc).
 
INPUT PROGRAM.
* Next vector will contain the column data.
VECTOR c(10F8.0).
LOOP #vars=1 TO 8.
LOOP #rows=1 TO 5.
LOOP #cols=1 TO 10.
COMPUTE c(#cols)=#vars.
END LOOP.
END CASE.
END LOOP.
END LOOP.
END FILE.
END INPUT PROGRAM.
LIST.

*We first save the file in a Tab delimited format.
SAVE TRANSLATE OUTFILE='C:\\TEMP\\raw_data.dat'
  /TYPE=TAB /MAP /REPLACE.

* The above is all preparatory  work.
* Hang on to you hat, the next 7 lines of syntax do the job.

NEW FILE.
INPUT PROGRAM.
VECTOR DATA(50).
* If you run this syntax more than once during you SPSS session.
* you will have to comment the next line after the first run.
*FILE HANDLE rawdata /NAME='C:\\TEMP\\raw_data.dat'.
DATA LIST FILE=rawdata FREE (TAB) /DATA1 TO DATA50.
END INPUT PROGRAM.
FLIP.

*clean up.
MATCH FILES FILE=* /DROP=case_lbl.
EXECUTE.