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
* Posted in newsgroup by rlevesque@videotron.ca on 2000/09/17.
* Suppose we have 8 variables and each one has 50 cases.
* However those cases are in 5 rows of 10 columns each.
* The task is to reformat each of the 8 variables into a single column.

* This section builds a sample data file which has the same format as your current file.
INPUT PROGRAM.
* This 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.

* Now will read the Tab delimited file.
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. 
*Yes ... FLIP is part of the solution ;-).
FLIP.

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