You are on page 1of 2

CHAPTER 13

SYNTAX WINDOW
SPSSWIN performs various procedures through the user-friendly dialog boxes, pulldown menus,
pushbuttons, etc. The user is oblivious to the underlying command language that instructs SPSSWIN to
execute various procedures. There are benefits to becoming familiar with pasting syntax into the Syntax
window. These include:
1.

Creating a record of the procedure(s) you used.

2.

Some SPSS commands and options can only be run through SPSS command language.

3.

A set of commands that will be used on more than one occasion can be pasted to the Syntax
window, saved, and run later from the Syntax window, saving the user time and effort.

Opening a new Syntax window


If a Syntax window is not already open, one is opened when you click on a PASTE pushbutton. A new
Syntax window can also be opened from the menus by clicking on FILE NEW SYNTAX .
NOTE: You can automatically have a Syntax Window open each time you use SPSSWIN by using the
EDIT OPTIONS window (under "General" click on "Yes for "Open syntax window at startup").
Open an existing Syntax window
If you have previously pasted, edited and saved syntax, you can retrieve the file containing the syntax by
clicking on FILE OPEN. This will open the Open File Dialog box. Under the "Files of type:" pull down
menu choose "Syntax (*.sps"). If necessary, use the "Look in" pulldown menu to locate the folder
containing the syntax file of interest. Double click on the file name when it appears in the Open File Dialog
box. The Syntax Editor Dialog box will open revealing the contents of the syntax file.
Using Command Syntax
Whenever you click on the PASTE pushbutton, the Syntax Editor is opened and the syntax associated
with the particular procedure is pasted into the editor. At this point you can do the following:
Save the syntax
You will be prompted in the Save As Dialog Box to name the syntax file. You might save the syntax simply
to have a record of the procedure(s) you used. Or, you may save the syntax so that it can be run again at
a later time.
Running commands from the Syntax Window
The following example derives from the 1991 U.S. General Social Survey: A frequency analysis is
requested for the variables "Happy" and "Life" (before running FREQUENCIES the syntax was pasted
into a syntax window). Later, in the same session a frequency analysis was requested (and syntax
pasted) for the variables "Popular" and "Thnkself." The Syntax Editor would contain the following:
FREQUENCIES
VARIABLES=happy life.
EXECUTE.
FREQUENCIES
VARIABLES=popular thnkself.
EXECUTE.
If this syntax is saved and later retrieved, one or both frequency analyses can be rerun from the syntax
window.

Running both procedures


In the Syntax Editor, click on RUN ALL.
Running one procedure
In the Syntax Editor, click and drag to highlight one procedure. [Be sure to highlight the command
Execute -- this tells SPSSWIN to begun running the analysis.] Then click on
RUN SELECTION.
How do you know where the syntax for a procedure "begins" and "ends"? A command begins on a new
line (continuation lines are indented at least one space) and ends with EXECUTE followed by a period (.)
Capturing syntax from the Output Log
SPSS will generate an "Output Log" as part of the output if this option has been chosen. To have the
output log appear in the Output Navigator click on EDIT OPTIONS NAVIGATOR and then click on
"Display commands in the log." The commands (syntax) that appear in the Output Navigator can be
copied and pasted into a syntax window.
Note: Similarly, the user can copy syntax from a "journal" file into a syntax window. The "journal"
maintains a record of all commands used in a session. This file ("SPSS.JNL") is found in the folder:
C:\WINDOWS\TEMP.
Editing syntax
Syntax appearing in the Syntax Editor can be edited. However, the user must be familiar with command
syntax. A discussion of command syntax goes beyond the scope of this manual. The reader is referred to
the SPSS Syntax Reference Guide. If the Syntax Guide was loaded with the installation of Version 9.0,
help for syntax will be available under HELP SYNTAX GUIDE BASE.
Try this:
1.
2.
3.
4.
5.
6.
7.
8.

Open the data file 1991 U.S. General Social Survey.


Open the FREQUENCIES Dialog Box.
Select the variables EDUC, PAEDUC, and MAEDUC
Within STATISTICS request the Mean.
Within CHARTS choose Histogram.
Returning to the FREQUENCIES Dialog Box, click on the PASTE pushbutton. This will take
you to the Syntax Editor window.
Click and drag to highlight the syntax. Then click on RUN ALL
You should then see the frequency analyses and histograms in the Output Navigator.

Later, when we focus on IF, COMPUTE, and RECODE, we will look at using the Syntax Window to
simplify the process of creating new variables.

You might also like