SPSS® Statistical Package

Contents

Description
Where to find SPSS
SPSS Instructions

What is SPSS?

SPSS is a comprehensive statistical package with substanital programming and data-transformation features. Capabilties include:

  • 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 an 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.
Contents

Where to find SPSS

SPSS version 6.13 is available on strauss.udel.edu, a 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 can 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 are no longer 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:

Contents


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 (CTRL-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 SPSS

The syntax for running a batch SPSS job on UNIX is:

spss -m command_file >! output_file

Substitute 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.spss

Type the commands you want SPSS to execute and save the file. To run SPSS with this command file type:

spss -m dataprep.spss >! dataprep.lst

at 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.lst

at the UNIX prompt.

To print this file at the Smith Hall network printers, type:

qpr -q smips dataprep.lst

To 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
Contents

UNIX 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, save the file, and exit pico, using ^X. Then type:
source .localalias
to activate the alias. This command will not be needed the next time you log in.

Now, to run batch SPSS with the command file called dataprep.spss, type:

ezspss dataprep

The 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".

batch
Instructions
Contents

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.spss

set 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 an 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.lst

at the UNIX prompt, or use the ezspss alias:

ezspss income1

To view the listing on the terminal screen, type:

more income1.lst

at the UNIX prompt.

To print the listing on the Smith Hall networked printers, type:

qpr -q smips income1.lst       

To print a file somewhereother than 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
Contents

Example 2: Reading data from an external file (UNIX batch run)

The name of the command file for this example is:

income2.spss

The example 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 an 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. 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  2 

To run the program type:

spss -m income2.spss >! income2.lst

at the UNIX prompt, or use the ezspss alias:

ezspss income2

To view the listing file on the terminal screen, type:

more income2.lst

at the UNIX prompt.

To print the listing at the Smith Hall networked printers, type:

qpr -q smips income2.lst

To print a file somewhere other than 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
Contents

Example 3: Reading data with fixed record layout and saving an 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 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 
2202 

The 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.spss

It shows how to read data from an external file 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., 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 an 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 that 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, at the UNIX prompt, type:

spss -m income3.spss >! income3.lst

or use the ezspss alias:

ezspss income 3

To view the listing file on the terminal screen, type:

more income3.lst

at the UNIX prompt.

To print the listing on the Smith Hall networked printers, type:

qpr -q smips income3.lst

To print a file somewhere other than 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
Contents

Example 4: Reading an SPSS system file

To input an 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 an 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.lst

at the UNIX prompt, or use the ezspss alias:

ezspss income4

To view the listing file on the terminal screen, type:

more income4.lst

at the UNIX prompt.

To print the listing on the Smith Hall networked printers, type:

qpr -q smips income4.lst

To print a file somewhere other than 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
Contents

Graphical user interface

On UNIX, you may start SPSS with the graphical interface by typing spss on an X-terminal or on a PC or a Mac emulating an X-terminal. For an X-terminal or PC/Mac emulation of an X-terminal type:

spss
With 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 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 you 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
Contents

SPSS 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 the 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.

Instructions
Contents

SPSS line mode

On UNIX, to use SPSS in line mode, type the following command:
spss -m

You may type commands at the prompt. Results are written to the screen as soon as procedures execute. To exit, type finish.

Instructions
Contents

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.
  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, deselect 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 a 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 5M

This 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 an SPSS system file into the SPSS data editor:

spss -data income.sav

Check the manual page for spss to view a list of command-line switches (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 smips

at the UNIX prompt. To do this automatically each time you log in, 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 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 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 are currently working on one large project and use SPSS for that and rarely, if ever, for other things. You may want to automatically read an 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".

Instructions
Contents

 

 

Search IT Help

My UD Search for forms & applications.