官术网_书友最值得收藏!

Reading delimited text data files

Here is a snapshot of a portion of a comma-delimited text file:

A delimiter is a character such as a comma that serves as a separator between elements across a line of data. A text file is a kind of computer file that is structured as a sequence of lines of electronic text, often using the ASCII character set. Such a file is easily viewed in Windows accessories such as Notepad. Note that row 1 of the comma-delimited text file is a header row containing variable names for the columns.

IBM SPSS Statistics can directly read a delimited text file. There are different implementations in different recent releases of IBM SPSS Statistics, but the capability exists on the File menu. In IBM SPSS Statistics 24, use the following path:

File | Import Data

Here is the Read CSV File dialog box:

The Read CSV File dialog box shows the name of the file and a literal listing of what it reads from the first lines of the source file.
By default, IBM SPSS Statistics expects to find variable names in the first row of data--the checkbox for First line contains variable names is checked by default. Additional checkboxes exist as well as drop bars to specify the delimiter character, Decimal Symbol, and Text Qualifier. An Advanced Options button invokes a Text Wizard with additional capability to read text files formatted in a variety of ways. Here, the default settings shown in the Read CSV File dialog box will work for the delimited text file we are analyzing. Finally, click on OK to read the file, or click on Paste to paste the constructed syntax to the syntax window.

Here is the pasted syntax (IBM SPSS Statistics version 24):

PRESERVE.
SET DECIMAL DOT.
GET DATA /TYPE=TXT
/FILE="C:\Users\Tony\Documents\KSBSPSSBOOK_DATA\chapter2\gss2014\gss2014extract.csv"
/ENCODING='UTF8'
/DELIMITERS=","
/QUALIFIER='"'
/ARRANGEMENT=DELIMITED
/FIRSTCASE=2
/DATATYPEMIN PERCENTAGE=95.0
/VARIABLES=
ID AUTO
MARITAL AUTO
AGE AUTO
HAPPY AUTO
sex AUTO
/MAP.
RESTORE.
CACHE.
EXECUTE.
DATASET NAME DataSet1 WINDOW=FRONT.

The subcommands have a close correspondence with the dialog box settings in the Read CSV File dialog box. The /TYPE, /ARRANGEMENT, and /DELIMITERS subcommands establish that the source file is a comma-delimited text file.

Running the syntax populates an IBM SPSS Statistics Data Editor window with the data. 

主站蜘蛛池模板: 丰城市| 临洮县| 房山区| 宝坻区| 台山市| 虹口区| 阿城市| 清镇市| 崇礼县| 团风县| 汉阴县| 乌鲁木齐市| 林周县| 正镶白旗| 开阳县| 密云县| 二连浩特市| 贵溪市| 偃师市| 莎车县| 盐池县| 黑山县| 呈贡县| 阳谷县| 西乌珠穆沁旗| 谢通门县| 罗山县| 绥德县| 芮城县| 福贡县| 乌鲁木齐市| 恩施市| 正蓝旗| 宁乡县| 新巴尔虎右旗| 贵港市| 潞西市| 玛曲县| 普安县| 广汉市| 海阳市|