The Very Basics of SPSS(ver.16 and up,Windows) ÷y Statistical Computing Group Research Data Services SAS,University of Pennsylvania Last modified:03/16/2009 This online seminar is to help you get started with basic data management and analysis in SPSS It is for those people who: Are new to statistical data work and want to learn to use SPSS to manage data and perform common analysis. Took some undergraduate(or perhaps some graduate)introductory statistics course in SPSS long ago and want to refresh their memory. SPSS is one of the most user-friendly commercial statistical packages.As such,even beginners of statistical analysis would find its point-and-click and dialogue boxes interface very approachable and easy to use.However,in the long run,you will benefit a lot more by learning SPSS by SPSS Syntax.The pros of the syntax approach are: An efficient way for documentation and reproducibility (this is the reason I would strongly discourage you from keeping relying on the point-and-click approach). Much quicker and efficient once you learn how to write and run syntax commands. Can perform things unavailable/inaccessible from the point-and-click menus So,this online seminar attempts to prepare you for writing syntax commands yourself in the future to perform simple data tasks and run basic procedures. Aside from this online seminar,you have access to a lot of great instructional SPSS resources online for free.We strongly recommend that you use those resources to the full. This online seminar assumes that you are using SPSS ver.16 and up.Be aware there are some significant changes between ver.15 and before and ver.16 on. Contents: 1.Getting Started:Let's Open SPSS and Bring in Data............ 2 2.How to Get Descriptive Statistics and Graphs...... 14 3.How to Define Variable Properties.................... 29 4.How to Create and Recode Variables3 5.How to Subset (Select)Data........... 45 6.How to Sort and Split Data........................ 53 7.Simple Regression Example.......... 57
The Very Basics of SPSS (ver.16 and up, Windows) Statistical Computing Group @ Research Data Services SAS, University of Pennsylvania Last modified: 03/16/2009 This online seminar is to help you get started with basic data management and analysis in SPSS. It is for those people who: Are new to statistical data work and want to learn to use SPSS to manage data and perform common analysis. Took some undergraduate (or perhaps some graduate) introductory statistics course in SPSS long ago and want to refresh their memory. SPSS is one of the most user-friendly commercial statistical packages. As such, even beginners of statistical analysis would find its point-and-click and dialogue boxes interface very approachable and easy to use. However, in the long run, you will benefit a lot more by learning SPSS by SPSS Syntax. The pros of the syntax approach are: • An efficient way for documentation and reproducibility (this is the reason I would strongly discourage you from keeping relying on the point-and-click approach). • Much quicker and efficient once you learn how to write and run syntax commands. • Can perform things unavailable/inaccessible from the point-and-click menus. So, this online seminar attempts to prepare you for writing syntax commands yourself in the future to perform simple data tasks and run basic procedures. Aside from this online seminar, you have access to a lot of great instructional SPSS resources online for free. We strongly recommend that you use those resources to the full. This online seminar assumes that you are using SPSS ver.16 and up. Be aware there are some significant changes between ver.15 and before and ver.16 on. Contents: 1. Getting Started: Let’s Open SPSS and Bring in Data................................................................. 2 2. How to Get Descriptive Statistics and Graphs.......................................................................... 14 3. How to Define Variable Properties........................................................................................... 29 4. How to Create and Recode Variables....................................................................................... 33 5. How to Subset (Select) Data..................................................................................................... 45 6. How to Sort and Split Data ....................................................................................................... 53 7. Simple Regression Example ..................................................................................................... 57 1
1.Getting Started:Let's Open SPSS and Bring in Data In this section,we will play with the SPSS windows and get a broad idea of what things look like in the SPSS environment.In so doing,we also learn how to bring data in SPSS.By the end of this section we will have a rough but good idea what role each window plays for your data management and analysis work and how to get SPSS ready for our work. First,let's create a working directory for this practice in whatever location you prefer.It is always a good idea to keep one project directory for one project.Let's call this new working directory "verybasicSPSS."Then download from here the data files we are going to use in this online workshop.Save them in the working directory you just created. Now,let's launch the program. Click on the SPSS icon,OR Choose from Window's Start menu SPSS 1x.x (whatever version you have;this workshop is using Version 16)for Windows: Start Programs SPSS for Windows SPSS 1x.x for Windows Some of you may have a dialogue box (called"SPSS for Windows 1x.x [your version]")popping up asking"What would you like to do?".In that case,let's just click on"Cancel"for now and go see what windows we have in the SPSS interface. You should be seeing an untitled SPSS Data Editor window now(like below). Untitled1 [DataSeto]-SPSS Data Editor -▣ File Edit View Data Iransform Analyze Graphs Utilities Add-ons Vindow Help 公周昌 厚卧:的帽由昌办雪多©● 1 Visible:0 of 0 Variables var var var var var var var 2 3 Data View Variable View SPSS Processor is ready The Data Editor window shows you the working(=currently open)dataset in a spreadsheet format.Of course,it is now new and empty.You see there are two sheets in this window,the Data View and the Variable View.Currently,the Data View is active (in yellow).You see a message from SPSS at the bottom of the window.Currently,it is "SPSS Processor is ready"for your work. 2
1. Getting Started: Let’s Open SPSS and Bring in Data In this section, we will play with the SPSS windows and get a broad idea of what things look like in the SPSS environment. In so doing, we also learn how to bring data in SPSS. By the end of this section we will have a rough but good idea what role each window plays for your data management and analysis work and how to get SPSS ready for our work. First, let’s create a working directory for this practice in whatever location you prefer. It is always a good idea to keep one project directory for one project. Let’s call this new working directory “verybasicSPSS.” Then download from here the data files we are going to use in this online workshop. Save them in the working directory you just created. Now, let’s launch the program. Click on the SPSS icon, OR Choose from Window’s Start menu SPSS 1x.x (whatever version you have; this workshop is using Version 16) for Windows: Start Programs > SPSS for Windows > SPSS 1x.x for Windows Some of you may have a dialogue box (called “SPSS for Windows 1x.x [your version]”) popping up asking “What would you like to do?”. In that case, let’s just click on “Cancel” for now and go see what windows we have in the SPSS interface. You should be seeing an untitled SPSS Data Editor window now (like below). The Data Editor window shows you the working (= currently open) dataset in a spreadsheet format. Of course, it is now new and empty. You see there are two sheets in this window, the Data View and the Variable View. Currently, the Data View is active (in yellow). You see a message from SPSS at the bottom of the window. Currently, it is “SPSS Processor is ready” for your work. 2
Before getting started with our work,let's change the output settings.From the menu bat at the top (of whichever window), Edit Options... This will bring you the "Options"dialogue box.Here,you can control what to display in your output.Click the"Viewer"tab.Here is one setting I strongly recommend that you choose: "Display commands in log."You will see why in a moment.For now,just check the box and click OK 团0 ptions General Viewer Data Currency Ouput Labels Charts Pivot Tables File Locations Scripts Initial Output State Title tem lcon Font Size: SansSerif Log 习49B☑四■ Shown Page Title Hidden Font Size: SansSerif 习09B四■ Justification Almn n 唱 Center Text Output ○Align g Fo吨 Size Monospaced 习o9B1四■ Display commands in the log OK Cancel apply Help Now,let's first bring in a data.We'll use these files for this practice. xls gss93.xls csv_gss93subset.csv fix gss93subset.dat GSS93 subset.sav *The second and third files are subsets of the last one"GSS93 subset"data(7 variables,97 observations)in different formats for our practice purpose. Reading Data from Excel Files We will start with importing the excel file"xls_gss93subset.xls"into SPSS.First,open the excel file and understand how it is formatted.The first row has variable names,and the data part is from the second row and below.Close the excel file and let's start reading this file into SPSS 3
Before getting started with our work, let’s change the output settings. From the menu bat at the top (of whichever window), Edit Options… This will bring you the “Options” dialogue box. Here, you can control what to display in your output. Click the “Viewer” tab. Here is one setting I strongly recommend that you choose: “Display commands in log.” You will see why in a moment. For now, just check the box and click OK. Now, let’s first bring in a data. We’ll use these files for this practice. xls_gss93.xls csv_gss93subset.csv fix_gss93subset.dat GSS93 subset.sav * The second and third files are subsets of the last one “GSS93 subset” data (7 variables, 97 observations) in different formats for our practice purpose. Reading Data from Excel Files We will start with importing the excel file “xls_gss93subset.xls” into SPSS. First, open the excel file and understand how it is formatted. The first row has variable names, and the data part is from the second row and below. Close the excel file and let’s start reading this file into SPSS. 3
Start SPSS by clicking on the SPSS icon or from the Window's Start menu.From the SPSS menu bat at the top,go: File Open Data.… Untitled1 [DataSeto]-SPSS Data Editor 回 Eile Edit Yiew Data Iransform Analyze Graphs Utilities Add-ons Window Help New Open A 用a Visible:0 of 0 Variables Open Database Syntex.… var var var □Read Text Data. output. 当goee Ctrl-F4 @sgrt… 目ss8 ctri-S Save As. 日Save All Data Export to Database SPSS Processor is ready This brings up a dialogue box"Open Data"as shown below.Go to your working directory “verybasicSPSS,”then select“Excel(*.xls)”format from“Files of type.”Then select the excel file"xls gss93.xls"you saved there.Then click Open.(see below for a visualized instruction). Open Data Look in: verybasicSP 电峰盟g (1)Go to your working 国s9ss93x5 directory where you saved the excel file. Recent (3)Select this file. G Desktop 自 My Documents (2)“-Files of type'”is (4)Click Open. Excel.This brings up 9 our excel file in the above window. My Computer File name: x×sg3s93.sav Open Files of type: Excelxs,*xsX*Xsm) Paste My Network Places Mnimize string widths based on observed values Cancel Now you should be seeing another dialogue box"Opening Excel Data Source
Start SPSS by clicking on the SPSS icon or from the Window’s Start menu. From the SPSS menu bat at the top, go: File Open Data… This brings up a dialogue box “Open Data” as shown below. Go to your working directory “verybasicSPSS,” then select “Excel (*.xls)” format from “Files of type.” Then select the excel file “xls_gss93.xls” you saved there. Then click Open. (see below for a visualized instruction). (4) Click Open. (3) Select this file. (2) “Files of type” is Excel. This brings up our excel file in the above window. (1) Go to your working directory where you saved the excel file. Now you should be seeing another dialogue box “Opening Excel Data Source.” 4
Opening Excel Data Source D:Documents and SettingsrrumimDesktopStatsisp1_verybasicSPsp1_verybasicSP_wrkfilewerybasicSPils_gss93.xls Read variable names from the first row of data Worksheet: xis gss93[A1:B01501] Range: Maximum width for string columns: 32767 Continue Cancel Help As we first checked,the excel file has variable names in the first row.So check the "Read variable names from the first row of the data"box.Click OK.Now you have a new,unsaved data in another SPSS Data Editor window.To save the data in the SPSS format,go from the pull- down menu: File Save Let's save it in your working directory with the name"xls gss93."Let's keep this data for a moment. Reading Data from Text Files (comma-separated-values) Okay,we are next try importing"csv_gss93subset.csv,"a text file in the comma separated values format.The first line contains variable names.From the menu bar at the top, File Open Data.… This again should bring up a dialogue box called"Open Data.Make sure you are looking in your working directory "verybasicSPSS."Since our file extension is.csv,we need to select"All Files(*.*)”from“Files of type.”Then“csv gss93 subset..csv”shows up in the window.Select it and click Open
As we first checked, the excel file has variable names in the first row. So check the “Read variable names from the first row of the data” box. Click OK. Now you have a new, unsaved data in another SPSS Data Editor window. To save the data in the SPSS format, go from the pulldown menu: File Save Let’s save it in your working directory with the name “xls_gss93.” Let’s keep this data for a moment. Reading Data from Text Files (comma-separated-values) Okay, we are next try importing “csv_gss93subset.csv,” a text file in the comma separated values format. The first line contains variable names. From the menu bar at the top, File Open Data… This again should bring up a dialogue box called “Open Data.” Make sure you are looking in your working directory “verybasicSPSS.” Since our file extension is .csv, we need to select “All Files(*.*)” from “Files of type.” Then “csv_gss93subset.csv” shows up in the window. Select it and click Open. 5