|
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 |
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:
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
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 -m< example1.sps > example1.lis
where "<" is the Unix re-direction symbol for input, and ">"
is the symbol for output
and "example1.sps" is your file of SPSS commands (syntax) and "example1.lis"
will be where SPSS puts the results of your commands after it runs them.
Running SPSS for Unix in X-Windows Mode: If running Exceed and logged onto a Unix serveron which SPSS is available, then at the Unix command prompt, type:
spss
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:
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:
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:
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:
2. Copying syntax from the output log. You can build a syntax file by copying command syntax from the log that appears in the Viewer. To use this method, you must select Display commands in the log in the Draft Viewer dialog box before running the analysis. Each command will then appear in the Output Viewer along with the output from the analysis.
If you want to copy the syntax that appears in the output Viewer, double-click on the log window that contains the syntax that you want to copy, highlight the syntax, select Edit:Copy, switch to the Syntax Editor, and select Edit:Paste.
3. Copying syntax from the journal file. By default, all commands executed during a session are recorded in a journal file named SPSS.JNL (set with Options on the Edit menu using General tab). You can edit the journal file and save it as a syntax file that you can use to repeat a previously run analysis. The journal file is a text file that can be edited like any other text file. Because error messages and warnings are also recorded in the journal file along with command syntax, you must edit out any error and warning messages that appear before saving the syntax file. Save the edited journal file with a different filename. Because the journal file is automatically appended or overwritten for each session, attempting to use the same filename for a syntax file and the journal file may yield unexpected results.
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.
Once you've created commands in the syntax window, you must submit them to be processed by SPSS. To submit commands, follow these steps:
COMPUTE bad=1 .
EXECUTE.
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.
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.
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:
*/This is a comment */
GET FILE = 'G:\apps\win32\spss8\examples\bank.sav' .
or
COMMENT This is a comment4.2.2 File Label
which continues on the second line
GET FILE = 'G:\apps\win32\spss8\examples\bank.sav' .
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' .
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,
| DOCUMENT | This file contains employee personnel information from bank personnel records. It should be treated as confidential . |
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:
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 |