Вы находитесь на странице: 1из 3

Unit 2 Syntax

Objectives
To successfully complete this learning unit, you will be expected to:
1.

Create data files with syntax.

2.

Understand SPSS syntax and the paste function.

3.

Create a data file with specified variables and include data.

Learning Activities
u02s1 Studies
Readings
Use your SPSS Essentials: Managing and Analyzing Social Sciences Data text to complete the following:

Chapter 3, "Types of Data" pages 1723. Look for important information on the "Data View" and
"Variable View" tabs at the lower right corner of the SPSS screen. Be sure you understand the
important difference between string variables and numeric variables.

Chapter 4, "Creating and Accessing Data Files (Part I)" pages 2534. Look for important information
on how to write syntax code to create data files.

u02d1 Understanding the Paste Button


Prior to the advent of Windows and menu commands, users of SPSS had to learn complex syntax language to write
programs instructing SPSS to perform analyses. Large, tattered manuals, about the size of a large city telephone
book, were often found in academic computer labs where students frequently consulted them to learn how to write
the commands properly. Failure to include some critical detail in the command syntax, such as forgetting a period or
leaving out a term, would result in the program failing to run.
Although SPSS commands can now be executed by menu selections, syntax programs are still an indispensable part
of efficient use of the software. It is much, much easier to produce syntax programs with fewer errors now, though.
Explain why.

Response Guidelines
Respond to one learner. Discuss your experience with syntax programs. How could this function be improved in the
future?

Resources

Attributes and Evaluation of Discussion Contributions.

Professional Communications and Writing Guide.

u02a1 Creating Data Files with Syntax


Download the file "Unit2_datalist.txt" and open it in Notepad, or simply open it in a new browser window and copy the
information from there. For this assignment:
1.

Open a syntax window in SPSS.

2.

Create a data file using syntax.

3.

Save the data file you created and submit it as an attachment.


o Go to your psy7615 folder using Windows Explorer. Create a new subfolder within
the psy7615 folder. Name the new folder Unit2.
o Open a syntax window in SPSS. This is accomplished by pulling down the FILE menu,
selecting NEW, and then selecting SYNTAX.
o Use command syntax as shown in Chapter 4 of the Kulas text to create a data file with the following
variables:
1.

CaseID, a seven digit integer.

2.

class, a two-character string variable.

3.

ethnic, a two-digit integer.

4.

gender, a one-digit integer.

5.

rate, an eight character number with two decimal places.

6.

score1, a three digit integer.

7.

zscore1, a five digit number with three decimal places

o Download the file Unit2_datalist.txt and open it in Notepad. In your text, you will notice there are
always two sub-commands in the "data list free" command named "begin data" and "end data."
Copy and paste the 12 lines of data from the Unit2_datalist.txt file into the first line after the
"begin data" sub-command. Make sure the "end data." statement is on the first line following the
last line of data from the downloaded file. That is, there should be no blank lines between "begin
data" and "end data."
o Run the syntax you have created. This is accomplished by pulling down the RUN menu, and
selecting "Run All". Note that you can run only part of the syntax listed in the syntax window by
selecting only a part of it in the window and using the "Selection" option under RUN. This
method will come in handy later in the course. After running your syntax, the data file should
appear in the SPSS Data Editor.

o Create a SAVE OUTFILE command to save the new data file you have created, using
the PASTE button. After running your syntax in the previous step to create your data file, go to
the Data Editorwindow to view your data file. It should look like a spreadsheet with your variable
names at the top of the columns. Use the FILE and SAVE AS menus at the top left of the SPSS
screen to select options to save your data file in the Unit2 subfolder inside of your psy7615
directory. Name the file unit2_data.sav. After you have typed the file name in the dialog box,
notice that you have the option to either SAVE or PASTE. Select the PASTE option. Now, go to
the Syntax Editor, where your original syntax to create the data file was typed. Notice that
SPSS has written a SAVE OUTFILEcommand for you under your original syntax. It did that
when you hit the PASTE button. Select this new syntax code with your mouse, pull down
the RUN menu, and click Selection. Your data file will be saved to the directory you specified in
the "Save As" dialog box, which you should notice is the same as the path in your SAVE
OUTFILE command. Now, save your new syntax file again so that your SAVE
OUTFILE command is included at the bottom of the syntax file you submit with your assignment.
o Save your syntax file to your Unit2 subfolder by opening the Syntax Editor window, pulling down
the FILE menu, and selecting SAVE AS. Navigate to your Unit2 subfolder, name the
fileunit2_syntax.sps, and save it.
Attach the following files to your assignment and upload them:
o unit2_data.sav
o unit2_syntax.sps

Resources

Creating Data Files with Syntax Scoring Guide.

"Unit2_datalist.txt".

Вам также может понравиться