wiesenavaneth
DESCRIPTION
TRANSCRIPT
![Page 1: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/1.jpg)
Wiesen (2007), IPMAAC Conference 1
Introduction to Using SPSS Command Files
Joel P. Wiesen, [email protected]
31th Annual IPMAAC ConferenceSt. Louis, MOJune 13, 2007
![Page 2: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/2.jpg)
Wiesen (2007), IPMAAC Conference 2
Outline
• Overview• Some command syntax details• Examples of command files• Tips• Exercises• Review• Q&A
![Page 3: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/3.jpg)
Wiesen (2007), IPMAAC Conference 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
![Page 4: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/4.jpg)
Wiesen (2007), IPMAAC Conference 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
![Page 5: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/5.jpg)
Wiesen (2007), IPMAAC Conference 5
Pros and Cons
EasierHarderLong analysesYesNoAll procedures
EasierHarderDocumentationEasierHarderDebuggingHarderEasierLearning curveEasierHarderRe-running
Command FileMenuFunctionality
![Page 6: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/6.jpg)
Wiesen (2007), IPMAAC Conference 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
![Page 7: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/7.jpg)
Wiesen (2007), IPMAAC Conference 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
![Page 8: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/8.jpg)
Wiesen (2007), IPMAAC Conference 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
![Page 9: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/9.jpg)
Wiesen (2007), IPMAAC Conference 9
How to Save a Command File
• File-Save• File extension: .SPS• Can use same name for data and sps files
![Page 10: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/10.jpg)
Wiesen (2007), IPMAAC Conference 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
![Page 11: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/11.jpg)
Wiesen (2007), IPMAAC Conference 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
![Page 12: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/12.jpg)
Wiesen (2007), IPMAAC Conference 12
What is a Command File?
• An ASCII text file• Contains SPSS commands written out• AKA syntax file
![Page 13: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/13.jpg)
Wiesen (2007), IPMAAC Conference 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
![Page 14: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/14.jpg)
Wiesen (2007), IPMAAC Conference 14
Example of an SPSS Command
• GET DATA / TYPE=XLS/ FILE='c:\path\file_name.xls'.
• This is one command– With two subcommands
• SPSS tries to use the Excel column heads as the variable names
![Page 15: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/15.jpg)
Wiesen (2007), IPMAAC Conference 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
![Page 16: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/16.jpg)
Wiesen (2007), IPMAAC Conference 16
Common & Important Commands
• Commands allow you to– Get data– Manipulate data– List data– Do statistical analyses– Save data
![Page 17: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/17.jpg)
Wiesen (2007), IPMAAC Conference 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.
![Page 18: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/18.jpg)
Wiesen (2007), IPMAAC Conference 18
Compute Command
• Used to change values• COMPUTE perscore = (score/60).• COMPUTE composite =
var1 + var2 + var3.• COMPUTE average = composite / 3.
![Page 19: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/19.jpg)
Wiesen (2007), IPMAAC Conference 19
IF
• IF (form = "A") zscore = (score – 44.5)/6.5
![Page 20: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/20.jpg)
Wiesen (2007), IPMAAC Conference 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
![Page 21: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/21.jpg)
Wiesen (2007), IPMAAC Conference 21
Save SPSS Data File
• SAVE OUTFILE = 'c:\path\filename.sav'.
• SAVE OUTFILE = 'c:\path\filename.sav'/ DROP ssn.
• SAVE OUTFILE = 'c:\path\filename.sav'/ KEEP id lastname grade.
![Page 22: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/22.jpg)
Wiesen (2007), IPMAAC Conference 22
TEMPORARY
• TEMPORARY.SELECT IF (eeo_gp = 1).LIST id written oral ppt /CASES = 15.
![Page 23: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/23.jpg)
Wiesen (2007), IPMAAC Conference 23
SORT
• SORT CASES BY grade.• LIST id lastname firstname grade.
• SORT CASES BY grade (A).
![Page 24: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/24.jpg)
Wiesen (2007), IPMAAC Conference 24
Variable Label
• VARIABLE LABEL failcol 'failed color vision'.
![Page 25: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/25.jpg)
Wiesen (2007), IPMAAC Conference 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' .
![Page 26: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/26.jpg)
Wiesen (2007), IPMAAC Conference 26
Save Non-SPSS Data File
• SAVE TRANSLATE OUTFILE ='c:\path\filename.xls' /TYPE=XLS / KEEP id gender eeo_gp age compos
/FIELDNAMES.
• This creates an Excel file with variable names for column heads.
![Page 27: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/27.jpg)
Wiesen (2007), IPMAAC Conference 27
Statistical Commands
• Means• Graph• Correlation• Many other commands
![Page 28: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/28.jpg)
Wiesen (2007), IPMAAC Conference 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.
![Page 29: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/29.jpg)
Wiesen (2007), IPMAAC Conference 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'.
![Page 30: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/30.jpg)
Wiesen (2007), IPMAAC Conference 30
Correlation
• CORRELATIONS /VARIABLES= oral written ppt/PRINT=TWOTAIL NOSIG/STATISTICS DESCRIPTIVES/MISSING=PAIRWISE .
![Page 31: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/31.jpg)
Wiesen (2007), IPMAAC Conference 31
Command File Example
• SPSS Program to Grade a Test
(See separate pdf file.)
![Page 32: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/32.jpg)
Wiesen (2007), IPMAAC Conference 32
Tips for Using Command Files
• Documenting• Debugging• Use of capitalization• Separate the major aspects of analyses
![Page 33: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/33.jpg)
Wiesen (2007), IPMAAC Conference 33
Document Your Files
• File name• Date created• Author• Log of changes over time• Outline file• Visual divisions of file into sections
![Page 34: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/34.jpg)
Wiesen (2007), IPMAAC Conference 34
Debugging
• Debugging individual commands• Debugging command logic
![Page 35: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/35.jpg)
Wiesen (2007), IPMAAC Conference 35
Debugging Individual Commands
• SPSS is very detail demanding• Look for:
– Missing or extra quotation marks– Unbalanced parentheses– Missing periods
![Page 36: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/36.jpg)
Wiesen (2007), IPMAAC Conference 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
![Page 37: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/37.jpg)
Wiesen (2007), IPMAAC Conference 37
Use of Capitalization
• Helpful convention– SPSS commands in upper case– Variable names in lower case
![Page 38: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/38.jpg)
Wiesen (2007), IPMAAC Conference 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
![Page 39: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/39.jpg)
Wiesen (2007), IPMAAC Conference 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
![Page 40: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/40.jpg)
Wiesen (2007), IPMAAC Conference 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
![Page 41: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/41.jpg)
Wiesen (2007), IPMAAC Conference 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
![Page 42: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/42.jpg)
Wiesen (2007), IPMAAC Conference 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.
![Page 43: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/43.jpg)
Wiesen (2007), IPMAAC Conference 43
Other Training Resources
• On line tutorials for SPSS– Many from colleges
• Listserves
![Page 44: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/44.jpg)
Wiesen (2007), IPMAAC Conference 44
Exercise 1
• Fetch data from an Excel file• Get average of oral and written scores• Save data to an SPSS .sav file
![Page 45: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/45.jpg)
Wiesen (2007), IPMAAC Conference 45
Exercise 2
• Get data from an Excel file• Get average of oral and written z-scores • Save data to an SPSS .sav file
![Page 46: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/46.jpg)
Wiesen (2007), IPMAAC Conference 46
Review
• Pros and cons of drop-down menu• How to use command files
![Page 47: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/47.jpg)
Wiesen (2007), IPMAAC Conference 47
Drop-Down Menus
• Easy to get started• Unwieldy for longer analyses• Easy to make undetected errors• Hard to proof analyses
![Page 48: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/48.jpg)
Wiesen (2007), IPMAAC Conference 48
How to Use Command Files
• Create files• Edit files• Save files• Name files• Run files
![Page 49: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/49.jpg)
Wiesen (2007), IPMAAC Conference 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
![Page 50: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/50.jpg)
Wiesen (2007), IPMAAC Conference 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
![Page 51: Wiesenavaneth](https://reader034.vdocuments.mx/reader034/viewer/2022051816/5458cda2b1af9f39378b574f/html5/thumbnails/51.jpg)
Wiesen (2007), IPMAAC Conference 51
Q&A’s
• The floor is open– Questions– Comments