Title: Introduction to SPSS Module II
1Introduction to SPSSModule II
- Hsin-Hui Lin, Ph.D.
- Paul M. Montebello, Ph.D.
Policy Planning Research Division Department of
Childrens Services Tennessee State
2Contents
- Review Module 1
- File Manipulation Functions
- Data Transformation Functions
- Working with Command Syntax
3Review of Module I
- SPSS Program Flow
- Data ? Syntax ? Output
- Using Data Files in SPSS
- Importing a Fixed-length File (.dbf/.xls)
- Importing a Fixed-length Text File (.txt)
- Importing a Variable-length Text File
4Review of Module I
- Working with Variables in SPSS
- Variable Names
- Variable Types
- Variable Labels
- Value Labels
- Missing Values
- Levels of Measurement
- Using the SPSS Data Editor
5File Manipulation Functions
- SPSS File Manipulation Functions
- Sort Cases
- Merge Files
- Select Cases
- Split File
- Restructure Data
6Sort Cases
- Sorts on Sorting Variables gt 1
- Ascending or Descending Order
- Multi-sort SPSS Sorts by Each Variable w/in
Categories of Prior Variable - For String Variables, Y Precedes y
7Sort Cases
8Sort Cases
9Merge Files
- Merge File Methods
- Merge files with the same variables, but
different cases - Merge files with the same cases, but different
variables
10Add Cases
11Add Cases
12Add Cases
13Add Cases Workshop
- Merge cases from Cohort2 with Cohort1
- Get Cohort2.sav from C\DCS_SPSS folder
- Sort ID and save the file
- Get Cohort1.sav from C\DCS_SPSS folder
- Sort ID and save the file
- Add cases in Cohort2.sav to Cohort1.sav
- Save the file to Cohort12.sav
14Add Variables
15Add Variables
16Add Variables
17Add Variables
18Add Variables Workshop
- Merge Variables from Custody1.sav with
Clientall.sav
19Select Cases
- Select Cases Creates Case Subgroups Based on
Specified Criteria - Variable values and ranges
- Date and time ranges
- Case numbers
- Arithmetic expressions
- Logical expressions
- Functions
20Select Cases
21Select Cases
22Select Cases Workshop
- Use Casestudy.sav
- Use the Select Cases Function on the Following
Criteria - Race21
- Gender11
23Split File
- Splits File into segments based on the value of
gt 1 grouping variables - Can specify lt 8 grouping variables
- Cases should be sorted by values of the grouping
variables in the same order that variables are
listed in the group based on list.
24Split File
25Split File
26Split File Workshop
- Use Casestudy.sav
- Use the Split File Function on Race2 to separate
race groups
27Transformation Functions
- Automatic Recode
- Recode Values
- Compute Variable
- Time Series Transformation
- Rank Cases
- Categorize Variables
28Automatic Recode
- Modifies Data Values by Recoding
- Used to combine/collapse categories
- Two Recode Options
- Recode into the same variable
- Recode into a new variable
29Automatic Recode
30Automatic Recode
31Automatic Recode
32Recode Values
- Recode
- Single values
- Range of values
- Missing values
- Recodes Old Value ? New Value
33Recode Values
34Recode Values
35Recode Values
36Recode Values Workshop
- Use Actcase.sav
- Recode RACE ? RACE2
- 1 White
- 2 Black
- 3 Multiple Races
- 4 Other
- 9 Missing
- Recode HISP ? HISP2
- 1 Yes
- 2 No
- 9 Missing
37Compute Variable
- Compute converts values based on the value of
other variables - Compute values for numerics or strings
- Create new or replace existing variables
- Compute values using logical conditions
- Can utilize 70 built-in functions
38Compute Variables
39Compute Dates
- Length of Stay BASEDATE - INTDT
- BASEDATE Value YRMODA (yr,mo,dy)
- INTDT Value YRMODA (yr,mo,dy)
40Compute Workshop
- Use Casestudy.sav
- Use the variable of CSIND to Calculate the Number
of Days in Custody (LOS) - BASEDATE 11/15/2002
41Rank Cases
- Rank Cases Creates New Variables Containing
Ranks, Scores or Percentiles - Can rank cases in either a/d order
- Can organize rank by grouping variables
- Offers several ranking types
- Offers several methods for ranking ties
42Rank Cases
43Rank Cases
44Rank Cases
45Categorize Variables
- Converts Continuous Numeric Data to a Discrete
Number of Categories - Categories are based on percentile groups
- Each group contains roughly the same N
46Categorize Variables
47Restructure Data
- Restructure Data Replaces the Current File with a
New Restructured File. - Three restructuring methods
- Restructure selected variables into cases
- Restructure selected cases into variables
- Transpose all data
48Restructure Rows to Columns
- In Variable View Change the Format of CNT from
F2.0 to F4.2
49Restructure Rows to Columns
50Restructure Rows to Columns
51Restructure Rows to Columns
52Restructure Rows to Columns
53Restructure Rows to Columns
54Restructure Rows to Columns
55Restructure Rows to Columns
56Restructure Workshop
- Restructure Data File
- Get F2FTemp.sav from C\DCS_SPSS folder
- Restructure data file from children with multiple
rows of custody episode to single row with
multiple columns.
57Working with Command Syntax
- Command Syntax Rules
- Creating Syntax from Dialog Boxes
- Running Command Syntax
58Command Syntax Rules
- Every Command Must Begin On New Line
- Every Command Must End With a Period
- Slashes Separate Most Subcommands
- Command Must Include Full Variable Names
- Text Within Apostrophes or Quotation Marks Must
Fit On a Single Line
59Command Syntax Rules
- Command Lines Must Be lt 80 Characters
- Command Lines Must Use Periods for Decimals
- Do Not Use Variable Names That End With Periods
60Command Syntax Rules
61Creating Syntax from Dialog
Click Paste to enter syntax from a dialog box to
a syntax window
62Creating Syntax from Dialog
63Running Command Syntax
- Highlight Command in Syntax Window
- Click Run on Syntax Window Toolbar
- Select Choice(s) from Run Menu
64Running Command Syntax
- All
- Runs all commands in the syntax window.
- Selection
- Runs the currently selected command(s) only.
- Current
- Runs command where the cursor is currently
located. - To End
- Runs all commands from the cursors current
location to the end of the command syntax
65Running Command Syntax
66Command Syntax Workshop
- Open the Syntax File
- Custody_Pattern.sps
- Run the Syntax by Section
- Review the Output File
- Debug the Syntax Command File