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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
Solution ID:    100008745
Product:    SPSS Base
Title:
Reading Comma delimited files with quoted strings in SPSS 10.0

Description:
Q. 
I have SPSS 10.0 for Windows. I am using the Read Text Data Wizard to read a
comma delimited file. My file has quotation marks around the values between
the commas. For example, the file looks like this:

"1","horse","farm" 

Most programs automatically drop the quotation marks from around the values.
However, when I use the Read Text Wizard, all of my variables are read in as
string and the quotes are retained. How can I read in the file without the
quotation marks? 

A. 
The Read Text Wizard in SPSS 10.0 will read everything in between each comma
literally, meaning that it will consider the quotation marks as part of the
data. However, the DATA LIST LIST command is designed to strip the quotation
marks from the values. DATA LIST LIST can only be used through syntax, but
you can use the Read Text Data Wizard to create syntax that can be modified
for use with DATA LIST LIST.

Modifying the Text Import Wizard Syntax:

1. Go through the Read Text Data Wizard as normal. In step six of six,
select Yes under "Would you like to paste the syntax?" and then click
Finish. 

2. A syntax window will open, and you should see something like the
following: 

GET DATA /TYPE = TXT
/FILE = 'C:\\comma.txt'
/DELCASE = LINE 
/DELIMITERS = "," 
/ARRANGEMENT = DELIMITED
/FIRSTCASE = 1 
/IMPORTCASE = ALL 
/VARIABLES = 
V1 A3 
V2 A7 
V3 A5 
. 
CACHE. 
EXECUTE. 

3. The DATA LIST LIST statement needs far less information than the GET DATA
command. In place of GET DATA, type DATA LIST LIST. Delete the /TYPE=TXT
subcommand, and remove the '/' from in front of FILE. Then delete the
remaining lines of syntax, only leaving the variable names and formats. The
modified syntax should now look like this:

DATA LIST LIST FILE = 'C:\\comma.txt'
/V1 A3 
V2 A7 
V3 A5 
. 
EXECUTE. 

4. The last steps before running the above syntax is to place a forward
slash (/) before the first variable name and place parentheses around each
of the variable formats. The names of the variables and their formats can
also be changed at this point, if desired. The syntax should now look
something like this:

DATA LIST LIST FILE = 'C:\\comma.txt'
/ id (F3.0) 
V2 (A7) 
V3 (A5) 
. 
EXECUTE. 

5. To run the syntax, highlight the command and then go to Run->Selection.

More information on using DATA LIST can be found in the SPSS 10.0 Syntax
Reference Guide, on pages 241 - 258.