SPSS Programming and Data Management: A Guide for SPSS and SAS Users

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

3rd edition, 2006.

Author(s): Raynald Levesque, SPSS Inc.
Edition: 3rd
Publisher: SPSS Inc.
Year: 2006

Language: English
Pages: 404

SPSS Programming and Data Management, 3rd Edition: A Guide for SPSS and SAS Users......Page 1
Table of Contents......Page 5
Using This Book......Page 17
Documentation Resources......Page 18
Data Management......Page 19
Creating Command Syntax Files......Page 21
Running SPSS Commands......Page 22
Syntax Rules......Page 23
Displaying Commands in the Log......Page 24
Displaying the Status Bar in Command Syntax Windows......Page 25
Protecting the Original Data......Page 26
Using Temporary Transformations......Page 27
Using Temporary Variables......Page 28
Lag Functions......Page 30
Using $CASENUM to Select Cases......Page 32
Using Comments......Page 33
Using SET SEED to Reproduce Random Samples or Values......Page 34
Divide and Conquer......Page 35
Defining Global Settings......Page 36
Installing Database Drivers......Page 39
Reading a Single Database Table......Page 41
Reading Multiple Tables......Page 43
Reading Excel Files......Page 46
Reading a “Typical” Worksheet......Page 47
Reading Multiple Worksheets......Page 49
Reading Text Data Files......Page 52
Simple Text Data Files......Page 53
Delimited Text Data......Page 54
Fixed-Width Text Data......Page 58
Text Data Files with Very Wide Records......Page 63
Reading Different Types of Text Data......Page 64
Reading Complex Text Data Files......Page 65
Mixed Files......Page 66
Grouped Files......Page 67
Nested (Hierarchical) Files......Page 70
Repeating Data......Page 75
Reading SAS Data Files......Page 77
Reading Stata Data Files......Page 79
Working with Multiple Data Sources......Page 81
Merging Files with the Same Cases but Different Variables......Page 85
Merging Files with the Same Variables but Different Cases......Page 89
Updating Data Files by Merging New Values from Transaction Files......Page 93
Aggregating Data......Page 95
Aggregate Summary Functions......Page 97
Weighting Data......Page 98
Changing File Structure......Page 100
Transposing Cases and Variables......Page 101
Cases to Variables......Page 102
Variables to Cases......Page 105
Variable Properties......Page 111
Value Labels......Page 114
Missing Values......Page 115
Custom Variable Properties......Page 116
Using Variable Properties As Templates......Page 118
File Properties......Page 119
Recoding Categorical Variables......Page 121
Banding Scale Variables......Page 122
Simple Numeric Transformations......Page 125
Arithmetic and Statistical Functions......Page 126
Random Value and Distribution Functions......Page 127
String Manipulation......Page 128
Combining String Values......Page 129
Taking Strings Apart......Page 130
Working with Dates and Times......Page 134
Date Input and Display Formats......Page 135
Date and Time Functions......Page 138
Finding and Displaying Invalid Values......Page 145
Excluding Invalid Data from Analysis......Page 148
Finding and Filtering Duplicates......Page 149
Data Validation Option......Page 152
Indenting Commands in Programming Structures......Page 155
Conditional Transformations......Page 156
Conditional Case Selection......Page 159
Simplifying Repetitive Tasks with DO REPEAT......Page 160
Vectors......Page 163
Disappearing Vectors......Page 165
Loop Structures......Page 167
Indexing Clauses......Page 168
Nested Loops......Page 169
Conditional Loops......Page 171
Using XSAVE in a Loop to Build a Data File......Page 172
Calculations Affected by Low Default MXLOOPS Setting......Page 174
Output Management System......Page 177
Adding Group Percentile Values to a Data File......Page 178
Bootstrapping with OMS......Page 182
Transforming OXML with XSLT......Page 187
“Pushing” Content from an XML File......Page 188
“Pulling” Content from an XML File......Page 191
Positional Arguments versus Localized Text Attributes......Page 200
Layered Split-File Processing......Page 201
Saving Data in SAS Format......Page 202
Saving Data in Stata Format......Page 203
Writing Data Back to a Database......Page 205
Exporting Results to Word, Excel, and PowerPoint......Page 208
Introduction......Page 209
Command Syntax for Scoring......Page 210
Missing Values in Scoring......Page 212
Building and Saving Predictive Models......Page 213
Commands for Scoring Your Data......Page 220
Including Post-Scoring Transformations......Page 221
Getting Data and Saving Results......Page 222
Running Your Scoring Job Using the SPSS Batch Facility......Page 223
Programming with SPSS and Python......Page 225
11. Introduction......Page 227
12. Getting Started with Python Programming in SPSS......Page 231
The spss Python Module......Page 232
Submitting Commands to SPSS......Page 233
Dynamically Creating SPSS Command Syntax......Page 235
Capturing and Accessing Output......Page 236
Python Syntax Rules......Page 238
Mixing Command Syntax and Program Blocks......Page 240
Handling Errors......Page 243
Using a Python IDE......Page 244
Supplementary Python Modules for Use with SPSS......Page 246
Getting Help......Page 247
Creating Blocks of Command Syntax within Program Blocks......Page 249
Dynamically Specifying Command Syntax Using String Substitution......Page 250
Using Raw Strings in Python......Page 253
Displaying Command Syntax Generated by Program Blocks......Page 254
Creating User-Defined Functions in Python......Page 255
Creating a File Handle to the SPSS Install Directory......Page 257
Choosing the Best Programming Technology......Page 258
Using Exception Handling in Python......Page 259
Debugging Your Python Code......Page 263
14. Working with Variable Dictionary Information......Page 267
Summarizing Variables by Measurement Level......Page 269
Listing Variables of a Specified Format......Page 270
Checking If a Variable Exists......Page 272
Creating Separate Lists of Numeric and String Variables......Page 273
Using Object-Oriented Methods for Retrieving Dictionary Information......Page 274
Getting Started with the VariableDict Class......Page 275
Defining a List of Variables between Two Variables......Page 278
Identifying Variables without Value Labels......Page 280
Retrieving Variable or Datafile Attributes......Page 284
Using Regular Expressions to Select Variables......Page 287
Using the Cursor Class......Page 289
Reducing a String to Minimum Length......Page 293
Using the spssdata Module......Page 296
Getting Started with the Spssdata Class......Page 297
Using Case Data to Calculate a Simple Statistic......Page 300
Getting Started with the XML Workspace......Page 303
Writing XML Workspace Contents to a File......Page 306
Using the spssaux Module......Page 307
17. Creating, Modifying, and Saving Viewer Contents......Page 317
Getting Started with the viewer Module......Page 318
Persistence of Objects......Page 319
Creating a Custom Pivot Table......Page 320
Modifying Pivot Tables......Page 323
Creating a Text Block......Page 326
Using the viewer Module from a Python IDE......Page 328
Migrating Command Syntax Jobs to Python......Page 329
Migrating Macros to Python......Page 333
Migrating Sax Basic Scripts to Python......Page 337
Reading Database Tables......Page 345
Reading Excel Files......Page 348
Merging Data Files......Page 350
Merging Files with the Same Cases but Different Variables......Page 351
Merging Files with the Same Variables but Different Cases......Page 352
Aggregating Data......Page 353
Assigning Variable Properties......Page 354
Value Labels......Page 355
Finding and Displaying Invalid Values......Page 357
Finding and Filtering Duplicates......Page 359
Recoding Data......Page 360
Banding Data......Page 361
Numeric Functions......Page 363
Random Number Functions......Page 364
String Concatenation......Page 365
String Parsing......Page 366
Calculating and Converting Date and Time Intervals......Page 367
Adding to or Subtracting from One Date to Find Another Date......Page 368
Extracting Date and Time Information......Page 369
Custom Functions, Job Flow Control, and Global Macro Variables......Page 370
Creating Custom Functions......Page 371
Job Flow Control......Page 372
Creating Global Macro Variables......Page 374
Setting Global Macro Variables to Values from the Environment......Page 375
A. Python Functions......Page 377
spss.Cursor Function......Page 378
spss.Cursor Methods......Page 380
spss.EvaluateXPath Function......Page 383
spss.GetHandleList Function......Page 384
spss.GetLastErrorLevel and spss.GetLastErrorMessage Functions......Page 385
spss.GetVariableFormat Function......Page 386
spss.GetVariableMeasurementLevel Function......Page 389
spss.GetVariableType Function......Page 390
spss.PyInvokeSpss.IsXDriven function......Page 391
spss.SetMacroValue Function......Page 392
spss.StopSPSS Function......Page 393
spss.Submit Function......Page 394
Index......Page 397