SPSS® Statistical Package
Contents
Description
Where to find SPSS
SPSS Instructions
If you still need help
Description
What is SPSS?SPSS is a comprehensive statistical package with substanital programming and data-transformation features. Capabilties include --
Contents
- Programming (e.g., computation, recodes, conditional execution and looping)
- Statistical analysis (e.g., descriptive statistics, tables, regression, t-test, ANOVA, factor analysis, logistic regression and time series)
- Matrix algebra
- Graphics (e.g., histogram, pie chart, scatter plot, line graph, and 3-D plots)
- Utilities (e.g., sorting, merging and table lookup, transposition and displaying the dictionary for a SPSS system file)
- Spreadsheet appearance: Using interactive graphical SPSS, data are displayed in a matrix similar to a spreadsheet. Data may be entered directly in this window, or read from a file.
Where to find SPSS
SPSS version 6.13 is available on strauss.udel.edu, the central UNIX server.The current version of SPSS for Windows is installed in public computing sites maintained by IT Client Support & Services.
Faculty and staff also obtain copies of the Windows and Mac versions for installation on departmental systems or their personal systems by paying an annual license fee. For details, see the UDeploy web page.
Contents
SPSS Instructions
This document primarily describes use of SPSS on the central UNIX server, with limited reference to SPSS for Windows and to the relationships between SPSS on UNIX and SPSS on Windows. Most of the syntax works on both UNIX and Windows versions of SPSS. The primary difference is that syntax commands on Windows must end with a period. The period is optional on UNIX.SPSS system files produced on UNIX now can be read directly with Windows SPSS. And system files produced on Windows can be read on UNIX. (Portable files no longer are needed.) Use ftp to transfer the file. Be sure binary transfer mode is set. This is the default for most ftp clients.
Overview: How do I use SPSS?
This section divides into five subsections. The first four describe the four ways to run spss on the central UNIX server.
- Batch mode -- noninteractively with a command file
- Graphical user interface -- point and click with the mouse (requires an X-terminal)
- SPSS Manager -- interactively with character-based SPSS manager
- Line Mode -- interactively with commands typed at the prompt (immediate execution)
The other subsection is --
- Options and setup you can control.
Batch Mode
Hint: A convenient way to run batch SPSS jobs is to open more than one window on UNIX. Use one window for the editor. Type spss commands into the editor and save the file, but do not exit the editor (^O with pico, :w with vi). Run the job and view the output in a second window. This strategy not only saves time but allows you to view diagnostics in one window while you type corrections into the editor.This section divides into several subsections --
General instructions: How to run batch SPSSUNIX alias for Batch SPSS
Example 1: Reading data from the command file
Example 2: Reading data from an external file
Example 3: Reading data with fixed record layout and saving a SPSS system file
Example 4: Retreiving a SPSS system file
General Instructions: How to run batch SPSS
The syntax for running a batch SPSS job on UNIX is --
spss -m command_file >! output_fileSubstitute the name of your command file for command_file, and substitute the name of your output file for output_file.You may use a UNIX editor to create a file containing the commands you want SPSS to execute. For example, to use the pico editor to create a command file called "dataprep.spss", type --
pico dataprep.spssType the commands you want SPSS to execute and save the file. To run SPSS with this command file type --
spss -m dataprep.spss >! dataprep.lstat the UNIX prompt. The output includes an annotated copy of your commands and the output from SPSS procedures. For this example, both types of output are written to the file dataprep.lst.You may view this file on the screen with the UNIX pager called "more". To view the output type --
more dataprep.lstat the UNIX prompt.To print this file at the Smith Hall network printers, type --
qpr -q smips dataprep.lstTo print the file somewhere besides Smith Hall, substitute the name of the local print queue for "smips." Print queue names are posted at computing sites. Or you can find them online.batch
Instructions
ContentsUNIX Alias for Batch SPSS
To avoid typing the "-m", ">!" and the name of the output file each time you run batch SPSS, define an alias called ezspss. To define the alias, add the following line to the end of your .localalias file, located in your home directory --
alias ezspss 'spss -m \!*:r.spss > ! \!$:r.lst'You can use the pico editor to add this command to your .localalias file. First, be sure you are in your home directory. Here are the commands --cd # Takes you to your home directory pico .localalias # Starts pico for editing .localalias(Note: Everything after the # is a comment.) Go to the bottom of the .localalias file, add the alias command, and save the file and exit pico, using ^X. Then type --source .localaliasto activate the alias. This command will not be needed the next time you logon.Now, to run batch SPSS with the command file called dataprep.spss, type --
ezspss dataprepThe alias duplicates what you get by typing "spss -m dataprep.spss >! dataprep.lst". For the alias to work, your command file must have an extension of "spss".Example 1: Reading data from the command file
If you have a small amount of data, it is convenient to put it in the same file that contains your SPSS commands. This example shows how to do that. The name of the command file for this example is
income1.spssset width=80. * Read data, set missing values for persinc *. data list free / gender race persinc. recode persinc (99=sysmis). begin data. 1 1 20 1 1 99 1 1 13 2 1 1 1 1 10 2 2 5 2 1 12 1 1 7 2 1 99 2 2 2 end data. * Produce descriptive statistics *. descriptives var all.
Each command must begin in column 1 (the first character on the line). The commands beginning with an asterisk ("*") are comments.
Each command in this example ends with a period. The periods are optional with UNIX SPSS but required with Windows SPSS.
The first statement sets a SPSS option named width. The width option determines the maximum number of characters in a line of the output file, in this example, 80. This restriction prevents lines from wrapping on a standard-width screen.
The "data list" command instructs SPSS to read the data in free format (data fields separated by at least one space). This command spans two lines. The forward slash on the second line of the command indicates that the names of the variables follow.
The "recode" command changes values of 99 for persinc to system missing.
The "begin data" statement signifies to SPSS that the data start on the next line. The "end data" statement following the last line of data signifies the end of the data.
Finally, the "descriptives" command produces descriptive statistics for all variables in the file -- mean, standard deviation, minimum, maximum, and valid number of observations.
To run the program in batch mode on UNIX, type --
spss -m income1.spss >! income1.lstat the UNIX prompt, or use the ezspss alias --
ezspss income1To view the listing on the terminal screen, type --
more income1.lstat the UNIX prompt.
To print the listing at the Smith Hall network printers, type --
qpr -q smips income1.lst To print a file somewhere besides Smith Hall, substitute the name of the local print queue for "smips." Print queue names are posted at computing sites. Or you can find them online.
Example 2: Reading data from an external file (UNIX batch run)
The name of the command file for this example is
income2.spssIt shows how to read data from an external data file and produce descriptive statistics. Otherwise it is the same as Example 1, which includes the data in the command file.
The new command file looks like
set width=80. * Read data, set missing values for persinc *. data list file='income.data' free / gender race persinc. recode persinc (99=sysmis). * Produce descriptive statistics *. descriptives var all.Each command must begin in column 1 (i.e., first character on the line). The commands beginning with an asterisk ("*") are comments.
Each command in this example ends with a period. The periods are optional with UNIX SPSS but required with Windows SPSS.
The first statement sets a SPSS option named width. The width option determines the maximum number of characters in a line of the output file, in this example, 80. This restriction prevents lines from wrapping on a standard-width screen.
The "data list" command instructs SPSS to read the data in free format (data fields separated by at least one space). This command spans two lines. The forward slash on the second line of the command indicates the names of the variables follow. Notice that the data file is indicated by the "file=" option.
The "recode" command changes values of 99 for persinc to system missing.
Finally, the "descriptives" command produces descriptive statistics for all variables in the file -- mean, standard deviation, minimum, maximum, and valid number of observations.
The data file is income.data. It is the same data as the data included in the command file for Example 1. Its contents look like --
1 1 20 1 1 99 1 1 13 2 1 1 1 1 10 2 2 5 2 1 12 1 1 7 2 1 99 2 2 2To run the program type --
spss -m income2.spss >! income2.lstat the UNIX prompt, or use the ezspss alias --
ezspss income2To view the listing file on the terminal screen, type --
more income2.lstat the UNIX prompt.
To print the listing at the Smith Hall network printers, type --
qpr -q smips income2.lstTo print a file somewhere besides Smith Hall, substitute the name of the local print queue for "smips." Print queue names are posted at computing sites. Or you can find them online.
Example 3: Reading data with fixed record layout and saving a SPSS system file
The record layout for most large ascii data files is fixed and contains no spaces between fields. This means that each field begins and ends at a specifed column in the file, and there is not are no separators like tabs or spaces between the fields. (Columns are one character wide, unlike spreadsheet columns). The data file for this example is --
1120 1199 1113 2101 1110 2205 2112 1107 2199 2202The record layout for this example is
Variable Column 1 Column 2 gender 1 1 race 2 2 persinc 3 4 The name of the command file for this example is
income3.spssIt shows how to read data from an external using fixed format and saves a permanent SPSS system file --
set width=80. * Read data, set missing values for persinc *. data list file='income.data' / gender 1 race 2 persinc 3-4. recode persinc (99=sysmis). * Save permanent SPSS system file. save out="income.sav".Each command must begin in column 1 (i.e., first character on the line). The commands beginning with an asterisk ("*") are comments.
Each command in this example ends with a period. The periods are optional with UNIX SPSS but required with Windows SPSS.
The first statement sets a SPSS option named width. The width option determines the maximum number of characters in a line of the output file, in this example, 80. This restriction prevents lines from wrapping on a standard-width screen.
The "data list" command instructs SPSS to read the data in fixed format (default). The data list command spans four lines. The forward slash on the second line of the command indicates the names of the variables follow.
Notice that variables whose data fields are only one character wide need not specify the first and last column separately (gender, race). But the field for persinc spans two columns; hence, both the beginning and ending columns must be specified, separated by a dash.
The "recode" command changes values of 99 for persinc to system missing.
Finally, the "save" command saves a permanent SPSS system file named "income.sav".
To run the program type --
spss -m income3.spss >! income3.lstat the UNIX prompt, or use the ezspss alias --
ezspss income3To view the listing file on the terminal screen, type --
more income3.lstat the UNIX prompt.
To print the listing at the Smith Hall network printers, type --
qpr -q smips income3.lstTo print a file somewhere besides Smith Hall, substitute the name of the local print queue for "smips." Print queue names are posted at computing sites. Or you can find them online.
Example 4: Reading a SPSS System File
To input a SPSS system file stored on disk, use the "get file" command. The following command file, named income4.spss, shows how to read the system file and report descriptive statistics for all variables in the file --
set width=80. * Read SPSS system file *. get file="income.sav". * Report descriptive statistics for all variables *. descriptives var all.Each command must begin in column 1 (i.e., first character on the line). The commands beginning with an asterisk ("*") are comments.
Each command in this example ends with a period. The periods are optional with UNIX SPSS but required with Windows SPSS.
The first statement sets a SPSS option named width. The width option determines the maximum number of characters in a line of the output file, in this example, 80. This restriction prevents lines from wrapping on a standard-width screen.
The "get file" command instructs SPSS to read the system file named income.sav. Notice no recode is included here. The result of the recode was saved in the system file produced by Example 3.
The descriptives command reports mean, standard deviation, minimum, maximum, and number of valid cases for each variable.
To run the program type --
spss -m income4.spss >! income4.lstat the UNIX prompt, or use the ezspss alias --
ezspss income4To view the listing file on the terminal screen, type --
more income4.lstat the UNIX prompt.
To print the listing at the Smith Hall network printers, type --
qpr -q smips income4.lstTo print a file somewhere besides Smith Hall, substitute the name of the local print queue for "smips." Print queue names are posted at computing sites. Or you can find them online.
Graphical User Interface
On UNIX, you may start SPSS with the graphical interface by typing "spss" on an X-terminal, or a PC or a Mac emulating an X-terminal. For an X-terminal or PC/Mac emulation of an X-terminal type --
spssWith this command, your terminal window is "frozen" until you exit SPSS. To run interactive spss and free your terminal window for typing UNIX commands, add an ampersand after the SPSS command --
spss &When you start SPSS two windows appear --the data window, and the output window.
Use the mouse to move and resize these windows to suit your preferences.
You may type data into the data-editor window or open an existing SPSS system file. SPSS expects system files to be named with an extension of "sav." To open a system data file click on File/Open/Data, select the file you wish to open and click OK. Alternatively, you can open a data file when you start SPSS by using the -data switch and the name of the file, for example
spss -data nhanes_data.sav &The data editor will open displaying the nhanes_data.sav data file.
Many standard operations are available through the menu buttons, including recodes, computing new variables, assigning missing values, weighting cases, merging, sorting, and statistical analysis. For example, to do statistical analysis, click "Statistics" then select the type of analysis want to run.
To print the contents of a window, click "File/Print..." then select "Setup...". Type the name of the UNIX print queue into the dialog box labeled "Printer:", for example, to print at Smith Hall, enter "smips". The names of UNIX print queues are posted at public computing sites and are available online.
To stop the SPSS processor before it finishes executing a command, select File/Stop SPSS Processor or press ^C.
To run the Windows version of SPSS proceed as with other Windows applications. Click "Start" at the bottom left of the screen (usually), select "Programs" then "SPSS."
Instructions
ContentsSPSS Manager
The SPSS Manager is a character-based windowing system. You negotiate through the windows and commands using "accelerator keys" like the function keys and escape sequences instead of the mouse.The window is split horizontally into two main parts, and a narrow strip at the bottom for displaying menus. The top section is the output section. It displays results of your calculations. The other main section is the editor. Type SPSS syntax here. ( example). Press the Esc 0 and select "Exit" to exit SPSS.
To get menu options, press the escape key and a number. Each escape sequence brings up a menu. A short summary of the menus is available online.
SPSS Line Mode
On UNIX, to use SPSS in line mode, type the following command
spss -mYou may type commands at the prompt. Results are written to the screen as soon as procedures execute. To exit, type "finish."
SPSS Options and Setup
Preferences for Graphical Interactive Sessions
Several preferences can be set by selecting "Options/Preferences" from the menu bar in the SPSS data editor. Most users probably will find the defaults satisfactory. We recommend two changes, however: (1) print commands in the output, and (2) turn the journal off.Printing commands in the output documents what you have done and helps you to learn the syntax. For example, if all the commands are printed in the output, there is no ambiguity about which data you are using, what transformations you have done on it, and whether you saved the latest transformations.
If the commands appear in the output, you probably don't need the journal. The journal is a file containing all commands you executed during a session but not the output from the commands.
To make these changes, unselect "Record syntax in journal" on the main preferences screen. Then click the "Output" button at the bottom of the screen, and in the "Display" box, select "Commands." "Errors and warnings" should be selected already. If it isn't, select it also.
Set Statement in the Command File
You can set SPSS options with a set statement in your command file, for example --
set width=80.This sets the maximum width of the output to 80 characters, useful if you are working on a character-based terminal that displays no more than 80 characters per line. See the SPSS Reference Guide for a list of set options.
Command-Line Switches
You can control some features of your SPSS run with command-line switches. The syntax of an UNIX command-line switch is a dash combined with one or more characters and no spaces. Often, the switch is a dash and a single character (e.g., -M). Usually the switch is followed by an "argument" which supplies the specifics of your preference. For example, to change the size of the memory allocated to spss, use the -s switch --
spss -s 5MThis instruction sets the memory size to five megabytes. Use a trailing K to specify memory in kilobytes, or omit a suffix to specify it in bytes.
Another switch automatically reads a SPSS system file into the SPSS data editor --
spss -data income.savCheck the manual page for spss to view a list of command-line switchs (man spss).
Designating the Printer
You can set the default printer by defining a UNIX environment variable named PRINTER. To set the default to Smith Hall, at the UNIX prompt, type --
setenv PRINTER smipsat the UNIX prompt. To do this automatically each time you logon, put the setenv command in your .localenv file in your home directory. You can use the pico editor, or any other UNIX editor, to insert the command --
cd # Go to your home directory pico .localenv # Start pico to edit .localenv(# starts a comment.) Go to the bottom of the file and type the above setenv UNIX command on a new line, then save the file and exit pico (^X).
The .profile.sps File
Commands you wish to execute automatically each time you run SPSS may be placed in a file called .profile.sps. It must be stored in your home directory.Suppose you want to set the width to 80 characters, set the default print and write format to F4.0 (instead of the standard default, F8.2), and turn off writing commands to a journal file (spss.jnl). You can put the set command in the .profile.sps --
set width=80 format=F4.0 journal=no.Any valid spss syntax may be placed in the .profile.sps. For example, suppose you currently are working on one large project and use SPSS for that and rarely, if ever, for other things. You may want to automatically read a SPSS system file for this project at the beginning of each session. You can put the get file command in the .profile.sps file --
get file="income.sav".
If you still need help
If you need help quickly, you may call the IT Help Center at 831-6000 between 8 a.m. and 5 p.m. Monday through Friday. Or you can submit a question through E-mail .
Last modified: February 11, 2002
This page maintained by Larry Hotchkiss.
Copyright © University of Delaware, 2002.