Introduction to SPSS:
Part II
Research Computing Support Group
res-consult@virginia.edu
© 1996,1997,1998, 1999 by the Rector and Visitors of the University of Virginia


Introduction to SPSS is a two-part computer workshop taught by the Research Computing Support Group of Information Technology and Communication, University of Virginia. The workshop is an overview of layout and procedures of SPSS for Windows or Macintosh, including file operations, data definition procedures, running basic descriptive statistics, data transformation procedures, and basic analytical procedures. Procedures are learned through hands-on work related to an actual research question.
For a schedule of the next SPSS workshop, please check out the courses page of the ITC Research Computing Support Group, (http://www.itc.Virginia.EDU/research/courses.html).
This document is the second part of the Introduction to SPSS workshop; the first part is also available online.

Prerequisites: This document presumes that you have familiarity with Windows 98/2000/XP and its commands. It will not review any DOS or Windows concepts such as filenames, paths, booting up, erasing files, using the mouse, scrolling, etceteras. If you are not yet comfortable with Windows and must use SPSS, please see the pointers in the appendix of Introduction to SPSS: Part I.


Table of Contents

  1. Reading Other Types Of Data
    1. Reading In A Microsoft Excel File
    2. Reading In A Tab-Delimited Data File
  2. Moving Between SPSS on Different Platforms
    1. Unix
    2. Macintosh
  3. Basics of using Syntax
    1. Opening a New SPSS Syntax Editor Window
    2. Creating SPSS Syntax
    3. Running Command Syntax
  4. Examples of Basic Syntax Commands
    1. Open an Existing SPSS Data File
    2. Data File Documentation
      1. Comments
      2. File Label
      3. Document
  5. Editing User Preferences
  6. Getting Help

1. Reading Other Types Of Data

The following are some types of formats which can be read into SPSS or into which you can save your SPSS data file:

Note: For spreadsheet and tab-delimited files, SPSS can read variables names contained within the first row of data files.

1.1 Reading In A Microsoft Excel File

As with the tab-delimited data, reading in an Excel file is straightforward.

Once the Excel file is in this format, you can read it into SPSS by simply going to File: Open, select Excel from under the option box "Files of Type," and locate the file.

Once you have located the file, if it's a newer Excel file, (Office 98 or later) you are opening, SPSS will display the following dialog box:

This box is asking whether the Excel file has variable names that appear in the first row of the data set. If you do have such variable names, check this box as above. Doing so, makes SPSS assign names to each of the new variables. You can also select which worksheet to read in if there are multiple worksheets in the file.

1.2 Reading In A Tab-Delimited Data File

To read in plain ASCII text data that is delimited by tabs (a common raw data format), you simply need to go to File: Open, select Tab-Delimited from under the option box "Files of Type," and locate the file.



The text import wizard will open to walk you through the import of your text file. You will need to select the delimiter, formats for your variables, whether you have variable names in the first row of the data set, etc.




2. Moving Between SPSS on Different Platforms

2.1 Unix

Moving SPSS files between Unix and Windows involves no translation or conversion. SPSS data files (*.sav) or syntax files (*.sps) can be sent or retrieved from your Unix account using a transfer utility such as FTP or the new Home Directory service at UVa. It is important to remember, however, that data files are binary files (and thus must be transferred in BINARY mode) and syntax files are text files (and thus must be transferred in ASCII mode).

Output files created in newer versions of SPSS for Windows (*.spo) cannot be opened in SPSS for Unix. If you want to open in SPSS for Unix your output generated in SPSS for Windows, you must first save the Windows output as a text file.

Moving Files between Windows and Unix:

SPSS for Unix can be run in either conventional batch mode or in the new X-Windows mode which emulates Windows. 2.2 Macintosh

Moving SPSS files between Macintosh and Windows involves a bit more work than between Unix and Windows. SPSS for Mac data files (*.sav) cannot be read by SPSS for Windows (or vice versa). Instead, you must first save the data file as an SPSS portable file (*.por) which can be read by any SPSS system (Unix, Windows, Macintosh). Portable files are ASCII files and thus should be transferred in ASCII mode if using a transfer utility (e.g. FTP).

SPSS syntax files (*.sps) are fully portable between SPSS for Windows and Mac. If transferred, they should be transferred in ASCII mode.

Output files can be transferred without conversion between SPSS for Mac and versions of SPSS for Windows prior to 7.5.x. In versions of SPSS for Windows 7.5.x and later, the output files (*.spo) cannot be transferred to SPSS for Mac without first saving the output file as a text file (*.txt). Output files from SPSS for Mac can be opened in newer versions of SPSS for Windows, but they will be opened in a syntax window.

Moving Files between Windows and Macintosh:


3. Basics of using Syntax

3.1 Opening a New SPSS Syntax Editor Window

In order to begin issuing SPSS syntax commands, you must have a Syntax Editor window open. If you do not currently have a Syntax window open, then do the following: Under File, select New, and then Syntax.

The Syntax Editor window looks like this:


3.2 Creating SPSS Syntax

Most commands are accessible from the menus and dialog boxes. However, some commands and options are available only by using the command language. The command language also allows you to save your jobs in a syntax file so that you can repeat your analysis at a later date.

Keep in mind the following simple rules when editing and writing command syntax:

Command syntax is case insensitive, and three-letter abbreviations can be used for many command specifications. You can use as many lines as you want to specify a single command. You can add space or break lines at almost any point where a single blank is allowed, such as around slashes, parentheses, arithmetic operators, or between variable names. For example:
FREQUENCIES
VARIABLES=JOBCAT GENDER
/PERCENTILES=25 50 75
/BARCHART.


and

freq var=jobcat gender /percent=25 50 75 /bar.


are both acceptable alternatives that generate the same results.

While it is possible to open a syntax window and type in commands, you can also let SPSS help you build your syntax file using one of the following methods:

3.2.1 The Designated Window:

If you have more than one open Syntax Editor window, command syntax is pasted into the designated Syntax Editor window. If you have more than one open Viewer window, output is routed to the designated Viewer window. The designated windows are indicated by a red exclamation point (!) in the status bar. You can change the designated windows at any time. One use of this feature is to have more than one OUTPUT window open and be able to save some procedures to one automatically, then switch the designated window to the other OUTPUT file and run additional procedures that save into that one.

The designated window should not be confused with the active window, which is the currently selected window. If you have overlapping windows, the active window appears in the foreground. If you open a new Syntax Editor or Viewer window, that window automatically becomes the active window and the designated window.

3.3 Running Command Syntax

Once you've created commands in the syntax window, you must submit them to be processed by SPSS. To submit commands, follow these steps:

  1. Highlight the commands you want to run in the syntax window.
  2. Submit the commands in one of the following ways:
    1. Click the Run button (the right-pointing triangle) on the syntax window toolbar. The Run button on the Syntax Editor toolbar runs the selected commands or the command where the cursor is located if there is no selection; or
    2. Select one of the choices from the Run menu located on the menu bar:
      1. All. Runs all commands in the syntax window.
      2. Selection. Runs the currently selected commands. This includes any commands partially highlighted.
      3. Current. Runs the command where the cursor is currently located.
      4. To End. Runs all commands from the current cursor location to the end of the command syntax file.
SPSS will hold all data transformations until you request a procedure that required it to "read" the data (e.g. FREQUENCY, CROSSTAB). While these transformations are being held, you will see the message "Transformations Pending" in the SPSS Status Window (located on the bottom right of the screen). If you want to force SPSS to run the transformations, you can include EXECUTE after the command. For example:
COMPUTE bad=1 .
EXECUTE.

4. Examples of Basic Syntax Commands

4.1 Open an Existing SPSS Data File

To open an SPSS data file, use the following syntax:

GET FILE = 'G:\apps\win32\spss8\examples\bank.sav' .
The path and filename must be enclosed in quotes (single or double does not matter). Again, note that the command ends with a period.

Submit this command to SPSS and the requested file should appear in the Data Editor.

4.2 Data File Documentation

It's best to leave a trail of comments and information behind you as you plunge through the data. Using variable labels and value labels, comments, file labels, and document commands all make the data analysis process that much smoother and easier to re-create or explain to someone else should the need arise.

4.2.1 Comments

Comments can be put anywhere in an SPSS file. They are highly recommended as a way to annotate your command program and output listing for future reference. You can indicate a comment in two ways:

The comment may run several lines as long as the preceding line does not end in a period and the lines after the first one (marked with an * or COMMENT) start in column 2. All comments that begin in column 1 MUST begin with an * or COMMENT. For example, the following are two examples of comment line in a syntax file:
*/This is a comment */
GET FILE = 'G:\apps\win32\spss8\examples\bank.sav' .


or

COMMENT This is a comment
which continues on the second line
GET FILE = 'G:\apps\win32\spss8\examples\bank.sav' .
4.2.2 File Label

The File Label provides a descriptive label for the data file. The File Label is printed on the first line of each page of output displayed by the program. The label can be up to 60 characters long. For example:

FILE LABEL 'bank data for discrimination lawsuit' .

4.2.3 Document

The DOCUMENT command saves a block of text of any length in an SPSS-format data file. The basic command is DOCUMENT followed by any length of text. The text can be entered on as many lines as needed. Blank lines can be used to separate paragraphs. A period at the end of a line terminates the command, so you should not place a period at the end of any line but the last. For example,

The text and the date it was entered are saved in the data file's dictionary, and can be displayed with the DISPLAY DOCUMENTS command.

5. Editing User Preferences

SPSS allows you to customize many aspects of the program to suit your preferences.  By selecting Options under the Edit menu, you can change such features as how your variables are displayed in output, the format of charts, where page breaks occur in your output, as well as the font used -- to name just a few.


  Some changes from the default that we recommend and that are used in all of the ITC Public Computing facilities and classrooms are:

Below is a brief explanation of some of the features on each of the Tabs in the dialogue box:


14. Getting Help

Statistical Consulting hours: For the hours when a statistical computing consultant is available, please contact the Research Computing Support Center by telephoning 243-8800 or e-mailing res-consult@virginia.edu

Helpful Web Pages:

 

---

 Research Computing Support Homepage

© 2009 by the Rector and Visitors of the University of Virginia.

The information contained on the University of Virginia’s Department of Information Technology and Communication (ITC) website is provided as a public service with the understanding that ITC makes no representations or warranties, either expressed or implied, concerning the accuracy, completeness, reliability or suitability of the information, including warrantees of title, non-infringement of copyright or patent rights of others. These pages are expected to represent the University of Virginia community and the State of Virginia in a professional manner in accordance with the University of Virginia’s Computing Policies.