SlideShare uma empresa Scribd logo
1 de 51
Baixar para ler offline
Introduction to Using SPSS
       Command Files

          Joel P. Wiesen, Ph.D.
jwiesen@appliedpersonnelresearch.com
    31th Annual IPMAAC Conference
              St. Louis, MO
             June 13, 2007

           Wiesen (2007), IPMAAC Conference   1
Outline
•   Overview
•   Some command syntax details
•   Examples of command files
•   Tips
•   Exercises
•   Review
•   Q&A

              Wiesen (2007), IPMAAC Conference   2
Overview
•   Two ways to use SPSS
•   Pros and Cons of each type of use
•   Quick review of SPSS windows
•   How to write command files
•   How to save a command file
•   How to run a command file


               Wiesen (2007), IPMAAC Conference   3
Two Ways to Use SPSS
• Drop-down menus
  – Point-and-click
  – Widely used
  – Fraught with problems
  – Tedious for long analyses
• Command syntax files
  – Not commonly taught in college
  – Provides more functionality

               Wiesen (2007), IPMAAC Conference   4
Pros and Cons
Functionality             Menu                      Command File
Re-running               Harder                       Easier
Learning curve           Easier                       Harder
Debugging                Harder                       Easier
Documentation            Harder                       Easier
Long analyses            Harder                       Easier
All procedures              No                         Yes


                 Wiesen (2007), IPMAAC Conference                  5
Quick Review of SPSS Windows
• Data editor
  – See data
  – Transform variables
• Output
  – Results from commands, including tables, charts
• Chart editor
  – Can edit graphs
• Syntax editor
  – Write and execute SPSS commands

                  Wiesen (2007), IPMAAC Conference    6
How To Write Command Files
• Paste from drop-down menus
  – Menu choices generate syntax automatically
• Modify previous command file
• Write commands in text file




              Wiesen (2007), IPMAAC Conference   7
Creating Syntax From Menus
• Use drop-down menus but do not run
• Choose PASTE
  – Creates a syntax window
• Save command file
• Run pasted commands




              Wiesen (2007), IPMAAC Conference   8
How to Save a Command File
• File-Save
• File extension: .SPS
• Can use same name for data and sps files




             Wiesen (2007), IPMAAC Conference   9
How to Run a Command File
• Open command file
  – File-Open
  – Click on .sps file in Windows Explorer
• Highlight all or part of command file
• Run commands in one of several ways
  – Click on right arrow
  – Control-R
  – Run-all
               Wiesen (2007), IPMAAC Conference   10
Some Command Syntax Details
•   What is a command file?
•   Command syntax structure
•   Example of an SPSS command
•   Some details of commands
•   Common and important commands




              Wiesen (2007), IPMAAC Conference   11
What is a Command File?
• An ASCII text file
• Contains SPSS commands written out
• AKA syntax file




            Wiesen (2007), IPMAAC Conference   12
Command Syntax Structure
• Name of command
  – May include some variable names
  – May included some command options
• Name of subcommand
  – May include variable names or command
    options
• Slashes used to start subcommands
• Can continue over multiple lines
• End command with a period or blank line
              Wiesen (2007), IPMAAC Conference   13
Example of an SPSS Command
• GET DATA
   / TYPE=XLS
   / FILE='c:pathfile_name.xls'.

• This is one command
  – With two subcommands
• SPSS tries to use the Excel column heads
  as the variable names
              Wiesen (2007), IPMAAC Conference   14
Some Details of Commands
•   Each command begins on a new line
•   Variable names cannot be abbreviated
•   Command may span lines
•   Max line length: 80 characters
•   Period or blank line terminates command
•   Command syntax is case insensitive


               Wiesen (2007), IPMAAC Conference   15
Common & Important Commands
• Commands allow you to
  – Get data
  – Manipulate data
  – List data
  – Do statistical analyses
  – Save data




               Wiesen (2007), IPMAAC Conference   16
Most Important Command
• Asterisk
• Identifies a comment line
• End comment with period or blank line

 * This is an example of a comment line.

 * The next two lines correct data errors.


             Wiesen (2007), IPMAAC Conference   17
Compute Command
• Used to change values
• COMPUTE perscore = (score/60).
• COMPUTE composite =
    var1 + var2 + var3.
• COMPUTE average = composite / 3.




            Wiesen (2007), IPMAAC Conference   18
IF
• IF (form = "A") zscore = (score – 44.5)/6.5




              Wiesen (2007), IPMAAC Conference   19
Create Ranks
• RANK VARIABLES = written oral ppt (A).
• Default is to create new variables
  – rwritten
  – roral
  – rppt
• Can specify names of new variables
• (A) means ascending

               Wiesen (2007), IPMAAC Conference   20
Save SPSS Data File
• SAVE OUTFILE = 'c:pathfilename.sav'.

• SAVE OUTFILE = 'c:pathfilename.sav'
   / DROP ssn.

• SAVE OUTFILE = 'c:pathfilename.sav'
   / KEEP id lastname grade.

             Wiesen (2007), IPMAAC Conference   21
TEMPORARY
• TEMPORARY.
  SELECT IF (eeo_gp = 1).
  LIST id written oral ppt /CASES = 15.




              Wiesen (2007), IPMAAC Conference   22
SORT
• SORT CASES BY grade.
• LIST id lastname firstname grade.

• SORT CASES BY grade (A).




             Wiesen (2007), IPMAAC Conference   23
Variable Label
• VARIABLE LABEL
    failcol 'failed color vision'.




                Wiesen (2007), IPMAAC Conference   24
Value Label
• VALUE LABEL eeo_gp 0 ‘Unknown'
   1 'Non-Minority' 2 'Minority' .

• VALUE LABEL eeo_gp
   0 'Unknown'
   1 'Non-Minority'
   2 'Minority' .

            Wiesen (2007), IPMAAC Conference   25
Save Non-SPSS Data File
• SAVE TRANSLATE OUTFILE =
  'c:pathfilename.xls' /TYPE=XLS
   / KEEP id gender eeo_gp age compos
  /FIELDNAMES.

• This creates an Excel file with variable
  names for column heads.

              Wiesen (2007), IPMAAC Conference   26
Statistical Commands
•   Means
•   Graph
•   Correlation
•   Many other commands




              Wiesen (2007), IPMAAC Conference   27
Means Command
• MEANS TABLES= oral written BY eeo_gp.
  – This minimal command will work
  – Commands have default settings


• MEANS TABLES= oral written BY eeo_gp
   / CELLS MEAN COUNT STDDEV.
  – This command is more specific.


              Wiesen (2007), IPMAAC Conference   28
Graph
• GRAPH /SCATTERPLOT(BIVAR)= oral
  WITH written
   /MISSING=LISTWISE
   /TITLE= 'Title goes here'
    'line 2 of title goes here‘
   /SUBTITLE= 'sub title goes here‘
   /FOOTNOTE= 'footnote goes here‘
    'line 2 footnote goes here'.

           Wiesen (2007), IPMAAC Conference   29
Correlation
• CORRELATIONS
  /VARIABLES= oral written ppt
  /PRINT=TWOTAIL NOSIG
  /STATISTICS DESCRIPTIVES
  /MISSING=PAIRWISE .




            Wiesen (2007), IPMAAC Conference   30
Command File Example
• SPSS Program to Grade a Test

 (See separate pdf file.)




             Wiesen (2007), IPMAAC Conference   31
Tips for Using Command Files
•   Documenting
•   Debugging
•   Use of capitalization
•   Separate the major aspects of analyses




               Wiesen (2007), IPMAAC Conference   32
Document Your Files
•   File name
•   Date created
•   Author
•   Log of changes over time
•   Outline file
•   Visual divisions of file into sections


                 Wiesen (2007), IPMAAC Conference   33
Debugging
• Debugging individual commands
• Debugging command logic




            Wiesen (2007), IPMAAC Conference   34
Debugging Individual Commands
• SPSS is very detail demanding
• Look for:
  – Missing or extra quotation marks
  – Unbalanced parentheses
  – Missing periods




               Wiesen (2007), IPMAAC Conference   35
Debugging Command Logic
• Look at data at various points in the file
  – List data
  – Do crosstabulations
• Do analyses in another software package
  – Excel
  – SAS
  – Minitab
  –R

               Wiesen (2007), IPMAAC Conference   36
Use of Capitalization
• Helpful convention
  – SPSS commands in upper case
  – Variable names in lower case




             Wiesen (2007), IPMAAC Conference   37
Separate the Major Aspects of
             Analyses
• Read and save
  – Verify data is read correctly
• Groom data
  – Transform variables
     • Change numbers 1 to 4 to letters A to D
  – Add variables
     • Name of data set
• Analyze data

                 Wiesen (2007), IPMAAC Conference   38
Name Various Files
• Use one basic name
  – Keep track of all files related to one project
• For example:
  – IPMAAC_2007.dat
  – Read_IPMAAC_2007.sps
  – Groom_IPMAAC_2007.sps
  – Analyze_IPMAAC_2007.sps
• Similar system to name output files
                Wiesen (2007), IPMAAC Conference     39
Display Commands in Output
•   Do this through menu
•   Edit – Options
•   Select the Viewer or Draft Viewer tab
•   Check the Display commands in the log




               Wiesen (2007), IPMAAC Conference   40
SPSS Training Resources
• SPSS built-in tutorial
  – Help-Tutorial-Working with syntax
• SPSS help menu
  – Help - Command Syntax Reference
  – Full syntax options
  – Gives examples
  – States limitations
• SPSS website
               Wiesen (2007), IPMAAC Conference   41
SPSS Help
• When cursor is in a command
  – Click Syntax Help button to find out what
    subcommands and keywords are available for
    the current command
• If the cursor is not in a command
  – Clicking the Syntax Help button to display an
    alphabetical list of commands
  – You can select the one you want.

               Wiesen (2007), IPMAAC Conference     42
Other Training Resources
• On line tutorials for SPSS
  – Many from colleges
• Listserves




               Wiesen (2007), IPMAAC Conference   43
Exercise 1
• Fetch data from an Excel file
• Get average of oral and written scores
• Save data to an SPSS .sav file




              Wiesen (2007), IPMAAC Conference   44
Exercise 2
• Get data from an Excel file
• Get average of oral and written z-scores
• Save data to an SPSS .sav file




              Wiesen (2007), IPMAAC Conference   45
Review
• Pros and cons of drop-down menu
• How to use command files




            Wiesen (2007), IPMAAC Conference   46
Drop-Down Menus
•   Easy to get started
•   Unwieldy for longer analyses
•   Easy to make undetected errors
•   Hard to proof analyses




               Wiesen (2007), IPMAAC Conference   47
How to Use Command Files
•   Create files
•   Edit files
•   Save files
•   Name files
•   Run files




                   Wiesen (2007), IPMAAC Conference   48
Summary
•   Start using SPSS drop-down menus
•   Next, paste menu commands
•   Write command files as soon as possible
•   This enables you to
    – Do longer, more complex analyses
    – Detect errors and proof analyses



                Wiesen (2007), IPMAAC Conference   49
Final Thoughts
• Look at SPSS programs written by others
• Become acquainted with SPSS commands
• Learn details of commands you use often




          Copies of this presentation are available at:
                       http://ipmaac.org



               Wiesen (2007), IPMAAC Conference           50
Q&A’s
• The floor is open
  – Questions
  – Comments




                Wiesen (2007), IPMAAC Conference   51

Mais conteúdo relacionado

Semelhante a Wiesenavaneth

Oracle Database Overview
Oracle Database OverviewOracle Database Overview
Oracle Database Overview
honglee71
 
Best practices data collection
Best practices data collectionBest practices data collection
Best practices data collection
Sherry Lake
 
9780538745840 ppt ch07
9780538745840 ppt ch079780538745840 ppt ch07
9780538745840 ppt ch07
Terry Yoast
 

Semelhante a Wiesenavaneth (20)

20170419 To COMPRESS or Not, to COMPRESS or ZIP
20170419 To COMPRESS or Not, to COMPRESS or ZIP20170419 To COMPRESS or Not, to COMPRESS or ZIP
20170419 To COMPRESS or Not, to COMPRESS or ZIP
 
Readme
ReadmeReadme
Readme
 
Take a Trip Into the Forest: A Java Primer on Maps, Trees, and Collections
Take a Trip Into the Forest: A Java Primer on Maps, Trees, and Collections Take a Trip Into the Forest: A Java Primer on Maps, Trees, and Collections
Take a Trip Into the Forest: A Java Primer on Maps, Trees, and Collections
 
Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...
Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...
Best Practices and Performance Tuning of U-SQL in Azure Data Lake (SQL Konfer...
 
Introduction to sas
Introduction to sasIntroduction to sas
Introduction to sas
 
MemSQL 201: Advanced Tips and Tricks Webcast
MemSQL 201: Advanced Tips and Tricks WebcastMemSQL 201: Advanced Tips and Tricks Webcast
MemSQL 201: Advanced Tips and Tricks Webcast
 
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
 
2012 03 08_dbi
2012 03 08_dbi2012 03 08_dbi
2012 03 08_dbi
 
data.ppt
data.pptdata.ppt
data.ppt
 
Sas - Introduction to working under change management
Sas - Introduction to working under change managementSas - Introduction to working under change management
Sas - Introduction to working under change management
 
An introduction to STATA.pdf
An introduction to STATA.pdfAn introduction to STATA.pdf
An introduction to STATA.pdf
 
firststeps
firststepsfirststeps
firststeps
 
Oracle Database Overview
Oracle Database OverviewOracle Database Overview
Oracle Database Overview
 
R - Get Started I - Sanaitics
R - Get Started I - SanaiticsR - Get Started I - Sanaitics
R - Get Started I - Sanaitics
 
Best practices data collection
Best practices data collectionBest practices data collection
Best practices data collection
 
202110 SESUG 43 To Compress or not
202110 SESUG 43 To Compress or not202110 SESUG 43 To Compress or not
202110 SESUG 43 To Compress or not
 
What's New in File-AID 16.03
What's New in File-AID 16.03What's New in File-AID 16.03
What's New in File-AID 16.03
 
9780538745840 ppt ch07
9780538745840 ppt ch079780538745840 ppt ch07
9780538745840 ppt ch07
 
Programmability in spss 14
Programmability in spss 14Programmability in spss 14
Programmability in spss 14
 
Programmability in spss statistics 17
Programmability in spss statistics 17Programmability in spss statistics 17
Programmability in spss statistics 17
 

Último

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
ssuserdda66b
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Último (20)

Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 

Wiesenavaneth

  • 1. Introduction to Using SPSS Command Files Joel P. Wiesen, Ph.D. jwiesen@appliedpersonnelresearch.com 31th Annual IPMAAC Conference St. Louis, MO June 13, 2007 Wiesen (2007), IPMAAC Conference 1
  • 2. Outline • Overview • Some command syntax details • Examples of command files • Tips • Exercises • Review • Q&A Wiesen (2007), IPMAAC Conference 2
  • 3. Overview • Two ways to use SPSS • Pros and Cons of each type of use • Quick review of SPSS windows • How to write command files • How to save a command file • How to run a command file Wiesen (2007), IPMAAC Conference 3
  • 4. Two Ways to Use SPSS • Drop-down menus – Point-and-click – Widely used – Fraught with problems – Tedious for long analyses • Command syntax files – Not commonly taught in college – Provides more functionality Wiesen (2007), IPMAAC Conference 4
  • 5. Pros and Cons Functionality Menu Command File Re-running Harder Easier Learning curve Easier Harder Debugging Harder Easier Documentation Harder Easier Long analyses Harder Easier All procedures No Yes Wiesen (2007), IPMAAC Conference 5
  • 6. Quick Review of SPSS Windows • Data editor – See data – Transform variables • Output – Results from commands, including tables, charts • Chart editor – Can edit graphs • Syntax editor – Write and execute SPSS commands Wiesen (2007), IPMAAC Conference 6
  • 7. How To Write Command Files • Paste from drop-down menus – Menu choices generate syntax automatically • Modify previous command file • Write commands in text file Wiesen (2007), IPMAAC Conference 7
  • 8. Creating Syntax From Menus • Use drop-down menus but do not run • Choose PASTE – Creates a syntax window • Save command file • Run pasted commands Wiesen (2007), IPMAAC Conference 8
  • 9. How to Save a Command File • File-Save • File extension: .SPS • Can use same name for data and sps files Wiesen (2007), IPMAAC Conference 9
  • 10. How to Run a Command File • Open command file – File-Open – Click on .sps file in Windows Explorer • Highlight all or part of command file • Run commands in one of several ways – Click on right arrow – Control-R – Run-all Wiesen (2007), IPMAAC Conference 10
  • 11. Some Command Syntax Details • What is a command file? • Command syntax structure • Example of an SPSS command • Some details of commands • Common and important commands Wiesen (2007), IPMAAC Conference 11
  • 12. What is a Command File? • An ASCII text file • Contains SPSS commands written out • AKA syntax file Wiesen (2007), IPMAAC Conference 12
  • 13. Command Syntax Structure • Name of command – May include some variable names – May included some command options • Name of subcommand – May include variable names or command options • Slashes used to start subcommands • Can continue over multiple lines • End command with a period or blank line Wiesen (2007), IPMAAC Conference 13
  • 14. Example of an SPSS Command • GET DATA / TYPE=XLS / FILE='c:pathfile_name.xls'. • This is one command – With two subcommands • SPSS tries to use the Excel column heads as the variable names Wiesen (2007), IPMAAC Conference 14
  • 15. Some Details of Commands • Each command begins on a new line • Variable names cannot be abbreviated • Command may span lines • Max line length: 80 characters • Period or blank line terminates command • Command syntax is case insensitive Wiesen (2007), IPMAAC Conference 15
  • 16. Common & Important Commands • Commands allow you to – Get data – Manipulate data – List data – Do statistical analyses – Save data Wiesen (2007), IPMAAC Conference 16
  • 17. Most Important Command • Asterisk • Identifies a comment line • End comment with period or blank line * This is an example of a comment line. * The next two lines correct data errors. Wiesen (2007), IPMAAC Conference 17
  • 18. Compute Command • Used to change values • COMPUTE perscore = (score/60). • COMPUTE composite = var1 + var2 + var3. • COMPUTE average = composite / 3. Wiesen (2007), IPMAAC Conference 18
  • 19. IF • IF (form = "A") zscore = (score – 44.5)/6.5 Wiesen (2007), IPMAAC Conference 19
  • 20. Create Ranks • RANK VARIABLES = written oral ppt (A). • Default is to create new variables – rwritten – roral – rppt • Can specify names of new variables • (A) means ascending Wiesen (2007), IPMAAC Conference 20
  • 21. Save SPSS Data File • SAVE OUTFILE = 'c:pathfilename.sav'. • SAVE OUTFILE = 'c:pathfilename.sav' / DROP ssn. • SAVE OUTFILE = 'c:pathfilename.sav' / KEEP id lastname grade. Wiesen (2007), IPMAAC Conference 21
  • 22. TEMPORARY • TEMPORARY. SELECT IF (eeo_gp = 1). LIST id written oral ppt /CASES = 15. Wiesen (2007), IPMAAC Conference 22
  • 23. SORT • SORT CASES BY grade. • LIST id lastname firstname grade. • SORT CASES BY grade (A). Wiesen (2007), IPMAAC Conference 23
  • 24. Variable Label • VARIABLE LABEL failcol 'failed color vision'. Wiesen (2007), IPMAAC Conference 24
  • 25. Value Label • VALUE LABEL eeo_gp 0 ‘Unknown' 1 'Non-Minority' 2 'Minority' . • VALUE LABEL eeo_gp 0 'Unknown' 1 'Non-Minority' 2 'Minority' . Wiesen (2007), IPMAAC Conference 25
  • 26. Save Non-SPSS Data File • SAVE TRANSLATE OUTFILE = 'c:pathfilename.xls' /TYPE=XLS / KEEP id gender eeo_gp age compos /FIELDNAMES. • This creates an Excel file with variable names for column heads. Wiesen (2007), IPMAAC Conference 26
  • 27. Statistical Commands • Means • Graph • Correlation • Many other commands Wiesen (2007), IPMAAC Conference 27
  • 28. Means Command • MEANS TABLES= oral written BY eeo_gp. – This minimal command will work – Commands have default settings • MEANS TABLES= oral written BY eeo_gp / CELLS MEAN COUNT STDDEV. – This command is more specific. Wiesen (2007), IPMAAC Conference 28
  • 29. Graph • GRAPH /SCATTERPLOT(BIVAR)= oral WITH written /MISSING=LISTWISE /TITLE= 'Title goes here' 'line 2 of title goes here‘ /SUBTITLE= 'sub title goes here‘ /FOOTNOTE= 'footnote goes here‘ 'line 2 footnote goes here'. Wiesen (2007), IPMAAC Conference 29
  • 30. Correlation • CORRELATIONS /VARIABLES= oral written ppt /PRINT=TWOTAIL NOSIG /STATISTICS DESCRIPTIVES /MISSING=PAIRWISE . Wiesen (2007), IPMAAC Conference 30
  • 31. Command File Example • SPSS Program to Grade a Test (See separate pdf file.) Wiesen (2007), IPMAAC Conference 31
  • 32. Tips for Using Command Files • Documenting • Debugging • Use of capitalization • Separate the major aspects of analyses Wiesen (2007), IPMAAC Conference 32
  • 33. Document Your Files • File name • Date created • Author • Log of changes over time • Outline file • Visual divisions of file into sections Wiesen (2007), IPMAAC Conference 33
  • 34. Debugging • Debugging individual commands • Debugging command logic Wiesen (2007), IPMAAC Conference 34
  • 35. Debugging Individual Commands • SPSS is very detail demanding • Look for: – Missing or extra quotation marks – Unbalanced parentheses – Missing periods Wiesen (2007), IPMAAC Conference 35
  • 36. Debugging Command Logic • Look at data at various points in the file – List data – Do crosstabulations • Do analyses in another software package – Excel – SAS – Minitab –R Wiesen (2007), IPMAAC Conference 36
  • 37. Use of Capitalization • Helpful convention – SPSS commands in upper case – Variable names in lower case Wiesen (2007), IPMAAC Conference 37
  • 38. Separate the Major Aspects of Analyses • Read and save – Verify data is read correctly • Groom data – Transform variables • Change numbers 1 to 4 to letters A to D – Add variables • Name of data set • Analyze data Wiesen (2007), IPMAAC Conference 38
  • 39. Name Various Files • Use one basic name – Keep track of all files related to one project • For example: – IPMAAC_2007.dat – Read_IPMAAC_2007.sps – Groom_IPMAAC_2007.sps – Analyze_IPMAAC_2007.sps • Similar system to name output files Wiesen (2007), IPMAAC Conference 39
  • 40. Display Commands in Output • Do this through menu • Edit – Options • Select the Viewer or Draft Viewer tab • Check the Display commands in the log Wiesen (2007), IPMAAC Conference 40
  • 41. SPSS Training Resources • SPSS built-in tutorial – Help-Tutorial-Working with syntax • SPSS help menu – Help - Command Syntax Reference – Full syntax options – Gives examples – States limitations • SPSS website Wiesen (2007), IPMAAC Conference 41
  • 42. SPSS Help • When cursor is in a command – Click Syntax Help button to find out what subcommands and keywords are available for the current command • If the cursor is not in a command – Clicking the Syntax Help button to display an alphabetical list of commands – You can select the one you want. Wiesen (2007), IPMAAC Conference 42
  • 43. Other Training Resources • On line tutorials for SPSS – Many from colleges • Listserves Wiesen (2007), IPMAAC Conference 43
  • 44. Exercise 1 • Fetch data from an Excel file • Get average of oral and written scores • Save data to an SPSS .sav file Wiesen (2007), IPMAAC Conference 44
  • 45. Exercise 2 • Get data from an Excel file • Get average of oral and written z-scores • Save data to an SPSS .sav file Wiesen (2007), IPMAAC Conference 45
  • 46. Review • Pros and cons of drop-down menu • How to use command files Wiesen (2007), IPMAAC Conference 46
  • 47. Drop-Down Menus • Easy to get started • Unwieldy for longer analyses • Easy to make undetected errors • Hard to proof analyses Wiesen (2007), IPMAAC Conference 47
  • 48. How to Use Command Files • Create files • Edit files • Save files • Name files • Run files Wiesen (2007), IPMAAC Conference 48
  • 49. Summary • Start using SPSS drop-down menus • Next, paste menu commands • Write command files as soon as possible • This enables you to – Do longer, more complex analyses – Detect errors and proof analyses Wiesen (2007), IPMAAC Conference 49
  • 50. Final Thoughts • Look at SPSS programs written by others • Become acquainted with SPSS commands • Learn details of commands you use often Copies of this presentation are available at: http://ipmaac.org Wiesen (2007), IPMAAC Conference 50
  • 51. Q&A’s • The floor is open – Questions – Comments Wiesen (2007), IPMAAC Conference 51