Importing and Exporting With SPSS for Windows 17 TUT 117



Similar documents
Using Adobe Dreamweaver CS4 (10.0)

Microsoft Access Basics

Pharmacy Affairs Branch. Website Database Downloads PUBLIC ACCESS GUIDE

Introduction to PASW Statistics

Introduction to IBM SPSS Statistics

Avery Dennison UK Consumer Helpline: Consumer

Lesson 07: MS ACCESS - Handout. Introduction to database (30 mins)

Create a New Database in Access 2010

Monthly Payroll to Finance Reconciliation Report: Access and Instructions

2. Unzip the file using a program that supports long filenames, such as WinZip. Do not use DOS.

SPSS for Windows importing and exporting data

Appendix A How to create a data-sharing lab

Introduction to Microsoft Access 2003

Advanced Excel 10/20/2011 1

Introduction to SPSS 16.0

Analyzing Data Using Excel

Software User's Guide

Microsoft Access Rollup Procedure for Microsoft Office Click on Blank Database and name it something appropriate.

ACCESS Importing and Exporting Data Files. Information Technology. MS Access 2007 Users Guide. IT Training & Development (818)

Using Microsoft Access Databases

Word 2010: Mail Merge to with Attachments

Using Delphi Data with Excel and Access

Basic Pivot Tables. To begin your pivot table, choose Data, Pivot Table and Pivot Chart Report. 1 of 18

How To Create A Powerpoint Intelligence Report In A Pivot Table In A Powerpoints.Com

XMailer Reference Guide

Querying the Data Warehouse Using Microsoft Access

Software User's Guide

Personal Portfolios on Blackboard

Search help. More on Office.com: images templates

SPSS 12 Data Analysis Basics Linda E. Lucek, Ed.D

SPSS: Getting Started. For Windows

Introduction. Why Use ODBC? Setting Up an ODBC Data Source. Stat/Math - Getting Started Using ODBC with SAS and SPSS

Using SPSS, Chapter 2: Descriptive Statistics

CREATING EXCEL PIVOT TABLES AND PIVOT CHARTS FOR LIBRARY QUESTIONNAIRE RESULTS

MAS 500 Intelligence Tips and Tricks Booklet Vol. 1

Opening a Database in Avery DesignPro 4.0 using ODBC

GETTING YOUR DATA INTO SPSS

USER GUIDE. Unit 2: Synergy. Chapter 2: Using Schoolwires Synergy

Help File. Version February, MetaDigger for PC

FileMaker Pro and Microsoft Office Integration

INTRODUCTION: SQL SERVER ACCESS / LOGIN ACCOUNT INFO:

Getting Started Guide SAGE ACCPAC INTELLIGENCE

Business Objects Version 5 : Introduction

Importing TSM Data into Microsoft Excel using Microsoft Query

Excel Database Management Microsoft Excel 2003

Autodesk Product Manager Tool

MICROSOFT OFFICE ACCESS NEW FEATURES

IBM SPSS Statistics 20 Part 1: Descriptive Statistics

Creating and Using Databases with Microsoft Access

Results CRM 2012 User Manual

Intro to Excel spreadsheets

Installing LearningBay Enterprise Part 2

MICROSOFT ACCESS 2007 BOOK 2

Microsoft Access 2010 Part 1: Introduction to Access

How to Create Database in Microsoft Excel 2003

By: Peter K. Mulwa MSc (UoN), PGDE (KU), BSc (KU)

IBM SPSS Statistics 22 Core System User's Guide

Creating a Distribution List from an Excel Spreadsheet

MoCo SMS Suite Quick Guides for Direct Marketing and CRM

MICROSOFT ACCESS STEP BY STEP GUIDE

Appendix 2.1 Tabular and Graphical Methods Using Excel

Importing from Tab-Delimited Files

Bank Account 1 September 2015

HOW TO COLLECT AND USE DATA IN EXCEL. Brendon Riggs Texas Juvenile Probation Commission Data Coordinators Conference 2008

Pastel Evolution BIC. Getting Started Guide

Creating Web Pages with Microsoft FrontPage

Instruction manual. testo easyheat Configuration and Analysis software

Charting LibQUAL+(TM) Data. Jeff Stark Training & Development Services Texas A&M University Libraries Texas A&M University

Accounts Receivable: Importing Remittance Data

How to Create and Send a Froogle Data Feed

Ohio University Computer Services Center August, 2002 Crystal Reports Introduction Quick Reference Guide

Importing Data from a Dat or Text File into SPSS

TimeValue Software Due Date Tracking and Task Management Software

Adobe Dreamweaver CC 14 Tutorial

SonicWALL GMS Custom Reports

Importing Contacts to Outlook

Excel for Data Cleaning and Management

Getting Started Guide

Making an online form in Serif WebPlus

Intro to Web Development

Working with Spreadsheets

Creating a Participants Mailing and/or Contact List:

What is a Mail Merge?

Scheduling Data Import from Avaya Communication Manager into Avaya Softconsole MasterDirectory

How To Write A File System On A Microsoft Office (Windows) (Windows 2.3) (For Windows 2) (Minorode) (Orchestra) (Powerpoint) (Xls) (

Creating Personal Web Sites Using SharePoint Designer 2007

Mail Merge Using Thunderbird. Bob Booth February 2009 AP-Tbird2

Mail Merge Creating Mailing Labels 3/23/2011

MS Access Lab 2. Topic: Tables

Learn how to create web enabled (browser) forms in InfoPath 2013 and publish them in SharePoint InfoPath 2013 Web Enabled (Browser) forms

Working together with Word, Excel and PowerPoint

Introduction to MS WINDOWS XP

Ansur Test Executive. Users Manual

Task Force on Technology / EXCEL

Microsoft Excel Basics

Excel 2003 A Beginners Guide

Information Server Documentation SIMATIC. Information Server V8.0 Update 1 Information Server Documentation. Introduction 1. Web application basics 2

Using Microsoft Excel to Manage and Analyze Data: Some Tips

NAIP Consortium Strengthening Statistical Computing for NARS SAS Enterprise Business Intelligence

Transcription:

Information Systems Services Importing and Exporting With TUT 117 Version 2.0 (Nov 2009)

Contents 1. Introduction... 3 1.1 Aim of this Document... 3 2. Importing Data from Other Sources... 3 2.1 Reading Excel 5 or Later Files... 3 Task 1: Import Data from Excel... 5 2.2 Using ODBC to read a MS Access Database File... 6 Task 2: Read Data from an Access 2002 Database... 6 2.3 The Text Data Import Wizard... 10 Task 3 Import Data (Fixed Format)... 11 Task 4 Import Data (Delimited)... 15 3. Exporting Results... 16 Task 5 Create Tables and Charts to Export... 17 Task 6 Save all output to a Word document... 18 Task 7 Save a selected table to an existing open Word file... 18 Task 8 Save all tables... 19 Task 9 Save a selected chart... 20 Task 10 Save all charts... 21 Information Systems Services Page 2 of 23

1. Introduction SPSS for Windows takes advantage of the Microsoft Windows (MS Windows) graphical environment. The aim of the product is to make statistics as straightforward and easy a task to accomplish on computer as possible. The menu system enables you to build up complex statistical commands quickly and easily using a point and click method, without involving detailed knowledge of the command language. 1.1 Aim of this Document This document is designed to demonstrate importing and exporting data and other objects. The document is intended for anyone wanting to use SPSS in the MS Windows environment. It is assumed that you already know how to login to the network, start MS Windows and perform basic MS Windows operations with the mouse. No prior knowledge of SPSS is assumed. Several SPSS data files are used in this introduction. Before you begin, download the zip file provided for use with this document. Open a web browser and go to the URL : http://iss.leeds.ac.uk/downloads/303/statistical_analysis Scroll down to locate the item titled Example file for Importing and Exporting With and right-click on the ZIP file. Select Save Link As (Save Target As in Internet Explorer). When the Save As dialog box appears, select a suitable directory and click Save. Go into Windows Explorer and double click the zip file. Click File / Extract All to unzip the data files. If you are using, or intending to use, SPSS for Windows on your own PC you will also find this document useful. If you want to obtain a copy of the software to run on your own PC you should contact the ISS IT Shop. The IT Shop sells copies of the software, provides details about installing the software and states the terms of the SPSS site licence. 2. Importing Data from Other Sources In addition to reading its own data files, SPSS has the facility to read text files and files created by many other applications e.g. Excel Microsoft Access SAS dbase 2.1 Reading Excel 5 or Later Files When reading Excel files, the following rules apply: Each column becomes a variable and the data type and width for each is determined by the data type and width in the Excel file. If the column contains a mixture of types (e.g. numeric and string), then the data type in SPSS is set to string and all values are read as valid string values. Information Systems Services Page 3 of 23

For numeric variables, blank cells are set to the system missing value (a full stop). For string variables, blanks cells are treated as valid string values. If the first row of the range of Excel data contains column headings, these become the names of the SPSS variables. Any column headings containing more than eight characters will be truncated to eight characters. If the first row does not contain variable names, default names will be allocated to the variables by SPSS. Information Systems Services Page 4 of 23

Task 1: Import Data from Excel Activity 1.1 Before importing the data, open the file students97.xls using Microsoft Excel, and observe the position of the data on this worksheet. Activity 1.2 Create a new SPSS data file by selecting New > Data from the File menu. Select Open > Data from the File menu and change the Files of Type box to Excel(*.xls). Select the file students97 and click Open. Activity 1.3 Complete the next dialog box as shown to specify the range, and position of variable names. Click OK. Figure 1 The Excel Data Source Dialog Box The file will be displayed in the SPSS Data Window. Figure 2 Imported Excel Data Notice that the width of the gender column needs changing to reflect the nature of the data. Either use the mouse to extend the width, or switch to Variable View and modify the Column property to 6. Save the file as an SPSS file (students.sav) in your folder. Information Systems Services Page 5 of 23

2.2 Using ODBC to read a MS Access Database File The process of reading records from a database table relies on the use of ODBC the Open Database Connectivity protocol. A data source consists of two essential pieces of information: the driver that will be used to access the data the location of the database that is to be accessed. In order to specify data sources, the appropriate drivers must be installed. The following ones can be installed from the SPSS CD ROM: SPSS Data Access Pack Microsoft Data Access Pack. Task 2: Read Data from an Access 2002 Database Comments This method may also be used to read an Excel spreadsheet. Activity 2.1 From the File menu select Open Database > New Query. The Database Wizard dialog box will be opened. Note that the currently defined data sources may be different from those shown. Select MS Access Database and click Next. Figure 3 SPSS Database Wizard Information Systems Services Page 6 of 23

Activity 2.2 At the ODBC login screen type the name and path of the required database file accstudents2002.mdb and then click O.K. (Your path will be different from the one shown.) Figure 4 ODBC Login Screen Activity 2.3 The Select Data dialog box now opens. To see the list of fields in the table, click the small plus sign to the left of the word tblstudents. Figure 5 Select Data Dialog Box Activity 2.4 At this point, individual fields could be selected. However, all fields are required for this example, so click the minus sign to the left of the word tblstudents to restore the screen to Figure 5 above. Information Systems Services Page 7 of 23

Activity 2.5 Use the mouse to drag the table over to the window on the right. Figure 6 Select Data Dialog Box Now we could click Next, and specify criteria for inclusion of each field. We could then modify the variable names. (Remember that in SPSS variable names are restricted to 8 characters and there are additional limiting constraints.) In this case, as all the fields are required with no filtering. Click Finish. The imported data set will be displayed. The Data View, shown below, shows that field widths require adjustment. The Variable View shows the current settings. Information Systems Services Page 8 of 23

Activity 2.6: Adjust the data layout. (i) Select Variable View. Modify the settings of Width and Columns to conform with the specifications indicated below. (ii) Return to Data View. The layout should now resemble the display below. Activity 2.7: Save the file as an SPSS system file called accstudents.sav N.B. This method may also be used to read Excel spreadsheet data. Information Systems Services Page 9 of 23

2.3 The Text Data Import Wizard The SPSS Text Wizard can read text data files in a variety of formats: Tab-delimited files Space delimited files Comma delimited files Fixed format files. Step 1 Step 2 Step 3 Step 4 Step 5 A predefined format can be applied, or the remaining steps in the Text Wizard can be followed. This requests information about the format of data which may be delimited (i.e. spaces, tabs, commas or other characters are used to separate variables), or fixed width, where each variable is recorded in the same column location of the record for each case in the file. The file may or may not contain variable names. Existing variable names which contain more than eight characters will be truncated. If no variable names are included SPSS will allocate default names. It is also necessary to describe the way cases are represented. Normally each line will represent a case and the first case will begin on line 1 if no variable names are supplied and line 2 otherwise. The number of cases to import may be specified so it is possible to import all cases, the first n cases, or a random sample. a) Delimited Files. This step will display the wizard s interpretation of the data file, and allows selection of the character or symbol used as a delimiter. b) Fixed Width Files. This step will display vertical lines on the file where the wizard thinks each variable begins. These can be moved if required. Allows control over the variable names, the data format that the Text Wizard will use to read each variable, and the variables which will be included in the data file. Values that contain invalid characters for the selected format will be treated as missing. In the final step, there is an opportunity to save the file specification for later use, or to paste the syntax. Information Systems Services Page 10 of 23

Task 3 Import Data (Fixed Format) Activity 3.1 From the menu select File > Read Text Data Change the Files of Type box to *.dat. Look in your folder for the file BCSurvival.dat, select it and then click Open. The Text Import Wizard dialogue window will be displayed. Figure 7: Text Import Wizard: Step 1 Specify No to the question Does your text file match a predefined format and click Next. Activity 3.2 In the next dialogue window,: (i) Choose Fixed Width to indicate how the variables are arranged. (ii) Choose No in answer to the question Are variable names included at the top of your file. The display should now resemble the window below. Figure 8: Text Import Wizard: Step 2 Information Systems Services Page 11 of 23

(iii) Click Next. Activity 3.3 Other required information includes the line number of the first case. In this example it is 1, but if the first row contained variable names the row number of the first case would be 2. In the current file, a case corresponds to a single record and so it occupies a single line. If a case contained several records it would be necessary to supply that information here. (i) Make the following selections: Figure 9 Text Import Wizard Step 3 (ii) Click Next. Activity 3.4 The next window allows alterations to be made to the arrangement of columns. Figure 10 Text Import Wizard Step 4 Information Systems Services Page 12 of 23

No modifications are necessary as the delimiter for this file is the space character so click Next. Activity 3.5 Since variable names were not read in with the data, SPSS has allocated the default names v1, v2 vn. Click on each variable name to select it, and then type the variable name. The first variable s details are shown below: Figure 11: Text Import Wizard Step 5 (i) Replace the dummy names V1, V2 etc. by the names id, age, pathsize, lnpos, histgrad, er, pr, status, pathscat, ln_yesno, time. To do this click on the column headed V1 and overtype the name V1 by id in the Variable name box. Then click on the next column and do the same for the next varable. (ii) When the all of the variable names have been changed, click Next. Activity 3.6 In the final dialogue window, shown below, click Finish. Figure 12: Text Import Wizard Step 6 Information Systems Services Page 13 of 23

The data should appear as follows: Figure 13 Imported Text File Activity 3.7 Save the file with the name bcsurvival. Notice that the file is now an SPSS data file which has the file extension sav. Clicking on the Variables button in the last dialogue window would allow deselection of variables. (in some situations not all the variables would be required). Activity 3.8: To view variable information select File > Display Data File Information > Working File Info from the menu. An output window will open in SPSS to show the information. A sample of this is shown below: Information Systems Services Page 14 of 23

Task 4 Import Data (Delimited) Activity 4.1 Select Read Text Data from the File menu. Find the file anxiety.txt in your folder, click on the file to select it and then click Open. Respond to the wizard s questions as follows: Step 1 Step 2 No (file does not match a predefined format). Choose Delimited and select Yes the variable names are included at the top of the file. Step 3 The first case of data begins on line 2. Each line represents a case. Import all of the cases. Step 4 Step 5 Step 6 Activity 4.2 Choose tab as the delimiter. All variables are to be imported, so just select Next. The file format is not required for later use, nor is the syntax required. Click Finish. The data will now appear in the data editor window. Save the file as an SPSS data file and call it anxiety1. If in Step 6 of the wizard, we had chosen to paste the syntax, the following code would have appeared in a Syntax Window: Figure 14 SPSS Syntax Window This code, which has been generated by the Text Data Import Wizard is written in the SPSS Command Language. By choosing the Run option in this window, the code would be executed and the data would be imported. In earlier versions of SPSS, it was necessary to understand this language in order to read in and analyse the data, and there are still types of analyses that can only be performed by writing SPSS code and running it from the syntax window. Information Systems Services Page 15 of 23

3. Exporting Results Pivot tables and text output from SPSS may be exported in HTML, text, Word/RTF, and Excel format. Charts may be saved in a variety of common formats used by other applications. Three options are available: Output Document. Exports any combination of pivot tables, text output, and charts. For HTML and text format, charts are exported in the currently selected chart export format. For HTML document format, charts are embedded by reference, and charts should be exported in a suitable format for inclusion in HTML documents. For text document format, a line is inserted in the text file for each chart, indicating the filename of the exported chart. For Word/RTF format, charts are exported in Windows metafile format and embedded in the Word document. Charts are not included in Excel documents. Output Document (No Charts). Exports pivot tables and text output. Any charts in the Viewer are ignored. Charts Only. Exports charts only. For HTML and text documents, export formats include: Windows metafile (WMF), Windows bitmap (BMP), encapsulated PostScript (EPS), JPEG, TIFF, PNG, and Macintosh PICT. For Word/RTF documents, charts are always exported in Windows metafile format. Information Systems Services Page 16 of 23

Task 5 Create Tables and Charts to Export To demonstrate the various ways of exporting results first create some SPSS tables and charts. Activity 5.1 Open the file census.sav. From the Analyze menu select Descriptive Statistics > Frequencies. Select the variables marital and relig for the analysis. Figure 15: The Frequencies Dialog Box Activity 5.2 Click the Charts button on the dialog box above, and select the Bar Charts option. Click Continue and then OK. Figure 16: Charts Dialog Box Information Systems Services Page 17 of 23

Task 6 Save all output to a Word document Activity 6.1 From within the OUTPUT window, select File Export. Activity 6.2 In the dialogue window displayed, enter C:\temp\alloutput in the field labelled File Name as shown below. Figure 17: Export Output (All output) Click OK. All the output objects will be saved in the named Word document. The alignment of columns within tables should be adjustable and charts should also be adjustable as picture objects. You are not forced to save the entire contents of the OUTPUT window. SPSS allows you to select an individual object, or perhaps a class of objects such as graphs, and to save selectively. The following examples illustrate these options Task 7 Save a selected table to an existing open Word file Activity 7.1 Select an individual table by clicking on it. (If you do not have any tables in your Output window run a Frequencies or Crosstabs analysis to create one). Activity 7.2 From the menu select Edit Copy. Information Systems Services Page 18 of 23

Activity 7.3 Move to the Word document and select Edit Paste Special Formatted Text (RTF). The table will be inserted directly into the document. Task 8 Save all tables A different method allows for all tables to be exported. Activity 8.1 From the menu within the OUTPUT window select Edit Select All Pivot Tables. All the tables within the OUTPUT window will be highlighted. Select File Export. Activity 8.2 (i) (ii) In the dialogue window displayed, specify Selected. In the field labelled File Name, enter c:\temp\alltables. The window should resemble the display below. Figure 18: Export Output (All tables) (iii) Click on OK. All tables will be saved in the named Word document. Information Systems Services Page 19 of 23

Task 9 Save a selected chart To save an individual chart directly into Word, the simplest method is to use Copy and Paste. This method has already been described (see Task 7 above). Alternatively, to save a chart into a file the Export facility can be used as follows. Activity 9.1 (i) (ii) (iii) (iv) Select an individual chart by clicking on it. Click on the right mouse and select Export. In the dialogue window displayed, specify Selected. In the field labelled Type (within the box labelled Document) change the Type to None (Graphics Only). (v) In the field labelled Type (within the box labelled Graphics) specify the Type as JPEG. (vi) In the field labelled File Name, enter c:\temp\graph. The window should resemble the display below. Figure 19: Export Output (Selected chart) (vii) Click on OK. The selected file will be saved in c:\temp\graph1.jpg. Note the addition of the digit 1 at the end of the filename. This is added by SPSS for reasons which will become clearer after the next example has been described. The chart may be inserted into a Word document using Insert Picture. Information Systems Services Page 20 of 23

Task 10 Save all charts A technique similar to that used to save all tables may be employed. Activity 10.1 From the menu within the OUTPUT window select Edit Select All Charts. All the charts within the OUTPUT window will be highlighted. Activity 10.2 Select File Export. (i) In the dialogue window displayed, specify Selected. (ii) Under the area labelled Document select Type as None (Graphics only) (iii) Under the area labelled Graphics, in the field labelled Root File Name, enter c:\temp\allgraphs. The window should resemble the display below. Figure 20: Export Output (All charts) (iv) Click on OK. The charts will be saved individually in the files shown in the Windows Explorer display below. Figure 21: Windows Explorer listing of files created Information Systems Services Page 21 of 23

The filenames are formed using the common prefix of allgraphs with the addition of a digit at the end. Note: Some care is needed in using Copy and Paste to move output into Word. For example, you could use Edit Select All Charts followed by Edit Copy and then use either Paste or Paste Special within Word to include the copied charts. The problem with this approach is that the collection of charts would be treated as one entity when inserted into Word. Any attempt to modify the attributes or alignment of one chart would cause the same changes to apply to all charts. For this reason, the use of the Export facility as illustrated above is the preferred method of moving multiple output objects into Information Systems Services Page 22 of 23

Information Systems Services Page 23 of 23