Labels

Learn the powerful enterprise adaptable database:

Getting Started With ADABAS & Natural

Monday, January 28, 2013

SPSS - Reading data from various sources

Data can be entered directly, or it can be imported from a number of different sources. The processes for reading data stored in IBM® SPSS® Statistics data files; spreadsheet applications, such as Microsoft Excel; database applications, such as Microsoft Access; and text files are all discussed here.

A) BASIC STRUCTURE OF SPSS DATA FILES
B) READING SPSS DATA FILES
C) READING DATA FROM SPREADSHEETS
D) READING DATA FROM A DATABASE
E) READING DATA FROM A TEXTFILE




A) BASIC STRUCTURE OF SPSS DATA FILES

1) IBM® SPSS® Statistics data files are organized by cases (rows) and variables (columns).


2) In this data file, cases represent individual respondents to a survey.
 


3) Variables represent responses to each question asked in the survey.
 




B) READING SPSS DATA FILES

1) IBM® SPSS® Statistics data files, which have a .sav file extension, contain your saved data.



2) To open demo.sav, an example file installed with the product:
From the menus choose: File > Open > Data...
Browse to and open demo.sav.


3) The data are now displayed in the Data Editor.




C) READING DATA FROM SPREADSHEETS

1) Rather than typing all of your data directly into the Data Editor, you can read data from applications such as Microsoft Excel. You can also read column headings as variable names.
 


2) From the menus choose:
File > Open > Data...
Select Excel (*.xls) as the file type you want to view.
Open demo.xls .


3) The Opening Excel Data Source dialog box is displayed, allowing you to specify whether variable names are to be included in the spreadsheet, as well as the cells that you want to import.
 

4) In Excel 95 or later, you can also specify which worksheets you want to import.
 
5) If the column headings do not conform to the IBM® SPSS® Statistics variable-naming rules, they are converted into valid variable names and the original column headings are saved as variable labels.
 
6) If you want to import only a portion of the spreadsheet, specify the range of cells to be imported in the Range text box.

7) Click OK to read the Excel file.

8) The data now appear in the Data Editor, with the column headings used as variable names.
 


9) Since variable names can't contain spaces, the spaces from the original column headings have been removed. For example, Marital status in the Excel file becomes the variable Maritalstatus. The original column heading is retained as a variable label.
 



D) READING DATA FROM A DATABASE

1) Data from database sources are easily imported using the Database Wizard.


2) Any database that uses ODBC (Open Database Connectivity) drivers can be read directly after the drivers are installed.

3) ODBC drivers for many database formats are supplied on the installation CD. Additional drivers can be obtained from third-party vendors.

4) One of the most common database applications, Microsoft Access, is discussed in this example.
 
5) From the menus choose:
Note: Depending on your installation, you may also see a list of OLEDB data sources on the left side of the wizard (Windows operating systems only), but this example uses the list of ODBC data sources displayed on the right side.

In the next step, you can specify the tables and variables that you want to import.
Click Next.



9) In the next step, you select which records (cases) to import.

If you do not want to import all cases, you can import a subset of cases (for example, males older than 30), or you can import a random sample of cases from the data source. For large data sources, you may want to limit the number of cases to a small, representative sample to reduce the processing time.
Click Next to continue.



10) Field names are used to create variable names. If necessary, the names are converted to valid variable names. The original field names are preserved as variable labels. You can also change the variable names before importing the database.


Click the Recode to Numeric cell in the Gender field. This option converts string variables to integer variables and retains the original value as the value label for the new variable.

Click Next to continue.




11) The SQL statement created from your selections in the Database Wizard appears in the Results step. This statement can be executed now or saved to a file for later use.

Click Finish to import the data.



12) All of the data in the Access database that you selected to import are now available in the Data Editor.




E) READING DATA FROM A TEXTFILE

1) Text files are another common source of data. Many spreadsheet programs and databases can save their contents in one of many text file formats.


2) Comma- or tab-delimited files refer to rows of data that use commas or tabs to indicate each variable. In this example, the data are tab delimited.
 
3) From the menus choose:

8) Because the variable names may have been truncated to fit formatting requirements, this dialog box gives you the opportunity to edit any undesirable names.

Data types can be defined here as well. For example, it's safe to assume that the income variable is meant to contain a certain dollar amount.

To change a data type:
Under Data preview, select the variable you want to change, which is Income in this case.

Select Dollar from the Data format drop-down list.

Click Next to continue.





9) Leave the default selections in this dialog box, and click Finish to import the data.


No comments:

Post a Comment