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
Solution ID:	 	100000537	

Title:
Writing value labels instead of values in an ASCII data set 
Description:
Q. 
I would like to write out an ASCII data file, but I would 
like to write out the value labels of the values instead 
of the actual values wherever appropriate. Can this be done? 

A. 
Yes, it can. Here is a way that this can be done: 
*** This job demonstrates how REPORT can be used to replace 
*** numeric data values with the value labels. 

* Create dummy data file for illustration purposes.
data list free / religion gender. 
begin data 
1 2 1 1 3 1 4 2 4 2 3 1 4 1 4 2 2 2 2 1 2 1 3 2 3 1 3 2 2 1 
3 2 3 1 4 1 4 1 4 1 2 1 2 1 2 2 1 2 1 1 1 2 1 2 2 1 4 1 4 1 
1 2 1 1 3 1 4 2 4 2 3 1 4 1 4 2 2 2 2 1 2 1 3 2 3 1 3 2 2 1 
3 2 3 1 4 1 4 1 4 1 2 1 2 1 2 2 1 2 1 1 1 2 1 2 2 1 4 1 4 1 
1 2 1 1 3 1 4 2 4 2 3 1 4 1 4 2 2 2 2 1 2 1 3 2 3 1 3 2 2 1 
3 2 3 1 4 1 4 1 4 1 2 1 2 1 2 2 1 2 1 1 1 2 1 2 2 1 4 1 4 1 
1 2 1 1 3 1 4 2 4 2 3 1 4 1 4 2 2 2 2 1 2 1 3 2 3 1 3 2 2 1 
3 2 3 1 4 1 4 1 4 1 2 1 2 1 2 2 1 2 1 1 1 2 1 2 2 1 4 1 4 1 
end data. 
variable labels religion '' /gender ''. 
value labels religion 1 'protestant' 2 'catholic' 3 'jewish' 4 'none' 
		/gender 1 'male' 2 'female'. 
compute caseid=1+caseid. 
leave caseid. 

* do job.
file handle out1 / name = 'report data' /recfm=f /lrecl=80. 
report format=list 
	/outfile=out1 
	/title=center '' 
	/variables=caseid religion (label) 	gender (label) 
	/break=(nobreak). 

*** This will create an ASCII data set that has the CASEID, 
*** RELIGION, and GENDER data written, but RELIGION and GENDER 
*** are string variables since they are represented by the 
*** value labels than the original values. If you wish to 
*** read the data, you would have to exit SPSS, then you may 
*** enter SPSS and use the following syntax: 

data list free file='report data' /caseid (f2) religion (a10) gender (a8).