Programming And Data Management For IBM SPSS Statistics 20: A Guide For .

1y ago
5 Views
1 Downloads
8.23 MB
440 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Lilly Kaiser
Transcription

i Programming and Data Management for IBM SPSS Statistics 20: A Guide for IBM SPSS Statistics and SAS Users Raynald Levesque and IBM Corp.

Note: Before using this information and the product it supports, read the general information under Notices on p. 419. This edition applies to IBM SPSS Statistics 20 and to all subsequent releases and modifications until otherwise indicated in new editions. Adobe product screenshot(s) reprinted with permission from Adobe Systems Incorporated. Microsoft product screenshot(s) reprinted with permission from Microsoft Corporation. Licensed Materials - Property of IBM Copyright IBM Corporation 1989, 2011. U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

Preface Experienced data analysts know that a successful analysis or meaningful report often requires more work in acquiring, merging, and transforming data than in specifying the analysis or report itself. IBM SPSS Statistics contains powerful tools for accomplishing and automating these tasks. While much of this capability is available through the graphical user interface, many of the most powerful features are available only through command syntax—and you can make the programming features of its command syntax significantly more powerful by adding the ability to combine it with a full-featured programming language. This book offers many examples of the kinds of things that you can accomplish using command syntax by itself and in combination with other programming language. For SAS Users If you have more experience with SAS for data management, see Chapter 32 for comparisons of the different approaches to handling various types of data management tasks. Quite often, there is not a simple command-for-command relationship between the two programs, although each accomplishes the desired end. Acknowledgments This book reflects the work of many members of the IBM SPSS staff who have contributed examples here and on the SPSS community, as well as that of Raynald Levesque, whose examples formed the backbone of earlier editions and remain important in this edition. We also wish to thank Stephanie Schaller, who provided many sample SAS jobs and helped to define what the SAS user would want to see, as well as Marsha Hollar and Brian Teasley, the authors of the original chapter “IBM SPSS Statistics for SAS Programmers.” A Note from Raynald Levesque It has been a pleasure to be associated with this project from its inception. I have for many years tried to help IBM SPSS Statistics users understand and exploit its full potential. In this context, I am thrilled about the opportunities afforded by the Python integration and invite everyone to visit my site at www.spsstools.net for additional examples. And I want to express my gratitude to my spouse, Nicole Tousignant, for her continued support and understanding. Raynald Levesque Copyright IBM Corporation 1989, 2011. iii

Contents 1 Overview 1 Using This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Documentation Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Part I: Data Management 2 Best Practices and Efficiency Tips 4 Working with Command Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Creating Command Syntax Files . . Running Commands . . . . . . . . . . . Syntax Rules . . . . . . . . . . . . . . . . Protecting the Original Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 5 6 6 Do Not Overwrite Original Variables. . Using Temporary Transformations . . . Using Temporary Variables . . . . . . . . Use EXECUTE Sparingly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 7 8 9 Lag Functions . . . . . . . . . . . . . . . . . . Using CASENUM to Select Cases. . . MISSING VALUES Command . . . . . . . WRITE and XSAVE Commands . . . . . . Using Comments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 11 12 12 12 Using SET SEED to Reproduce Random Samples or Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Divide and Conquer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Using INSERT with a Master Command Syntax File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Defining Global Settings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3 Getting Data into IBM SPSS Statistics 17 Getting Data from Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Installing Database Drivers . . . . . Database Wizard . . . . . . . . . . . . . Reading a Single Database Table . Reading Multiple Tables. . . . . . . . Copyright IBM Corporation 1989, 2011. . . . . . . . . iv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 18 18 20

Reading IBM SPSS Statistics Data Files with SQL Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Installing the IBM SPSS Statistics Data File Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Using the Standalone Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Reading Excel Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Reading a “Typical” Worksheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Reading Multiple Worksheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Reading Text Data Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Simple Text Data Files . . . . . . . . . . . . . . . Delimited Text Data . . . . . . . . . . . . . . . . . Fixed-Width Text Data . . . . . . . . . . . . . . . Text Data Files with Very Wide Records . . Reading Different Types of Text Data . . . . Reading Complex Text Data Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 31 34 38 38 40 Mixed Files . . . . . . . . . . . . . . Grouped Files . . . . . . . . . . . . Nested (Hierarchical) Files . . Repeating Data . . . . . . . . . . . Reading SAS Data Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 41 43 47 48 . . . . . . . . . . . . . . . Reading Stata Data Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Code Page and Unicode Data Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 4 File Operations 53 Using Multiple Data Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Merging Data Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Merging Files with the Same Cases but Different Variables . . . . . . . . Merging Files with the Same Variables but Different Cases . . . . . . . . Updating Data Files by Merging New Values from Transaction Files . . Aggregating Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 59 62 63 Aggregate Summary Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Weighting Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Changing File Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Transposing Cases and Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Cases to Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 Variables to Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 v

5 Variable and File Properties 75 Variable Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 Variable Labels . . . . . . . . . . . . . . . . . . . . Value Labels . . . . . . . . . . . . . . . . . . . . . . Missing Values . . . . . . . . . . . . . . . . . . . . Measurement Level . . . . . . . . . . . . . . . . . Custom Variable Properties . . . . . . . . . . . Using Variable Properties as Templates . File Properties . . . . . . . . . . . . . . . . . . . . . . . . 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Data Transformations . . . . . . . 77 78 78 79 79 80 81 83 Recoding Categorical Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Binning Scale Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Simple Numeric Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 Arithmetic and Statistical Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 Random Value and Distribution Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 String Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 Changing the Case of String Values . . Combining String Values . . . . . . . . . . Taking Strings Apart . . . . . . . . . . . . . Changing Data Types and String Widths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 89 90 93 Working with Dates and Times . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 Date Input and Display Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Date and Time Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 7 Cleaning and Validating Data 102 Finding and Displaying Invalid Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 Excluding Invalid Data from Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 Finding and Filtering Duplicates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 Data Preparation Option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 8 Conditional Processing, Looping, and Repeating 110 Indenting Commands in Programming Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 vi

Conditional Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 Conditional Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 Conditional Case Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 Simplifying Repetitive Tasks with DO REPEAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 ALL Keyword and Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 Vectors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 Creating Variables with VECTOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 Disappearing Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 Loop Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Indexing Clauses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Nested Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Conditional Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using XSAVE in a Loop to Build a Data File. . . . . . . . . . . . Calculations Affected by Low Default MXLOOPS Setting . 9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exporting Data and Results . . . . . 120 120 122 123 124 126 Exporting Data to Other Applications and Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 Saving Data in SAS Format . . . . . . . . . . . . . . . . . . . . . . . Saving Data in Stata Format. . . . . . . . . . . . . . . . . . . . . . . Saving Data in Excel Format. . . . . . . . . . . . . . . . . . . . . . . Writing Data Back to a Database . . . . . . . . . . . . . . . . . . . Saving Data in Text Format. . . . . . . . . . . . . . . . . . . . . . . . Reading IBM SPSS Statistics Data Files in Other Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 127 128 128 131 131 Installing the IBM SPSS Statistics Data File Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 Example: Using the Standalone Driver with Excel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 Exporting Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 Exporting Output to Word/RTF . . . . . . . . . . . . . . . . . . . . . Exporting Output to Excel. . . . . . . . . . . . . . . . . . . . . . . . . Using Output as Input with OMS . . . . . . . . . . . . . . . . . . . Adding Group Percentile Values to a Data File . . . . . . . . . Bootstrapping with OMS . . . . . . . . . . . . . . . . . . . . . . . . . Transforming OXML with XSLT . . . . . . . . . . . . . . . . . . . . . “Pushing” Content from an XML File . . . . . . . . . . . . . . . . “Pulling” Content from an XML File . . . . . . . . . . . . . . . . . XPath Expressions in Multiple Language Environments . . Layered Split-File Processing. . . . . . . . . . . . . . . . . . . . . . Controlling and Saving Output Files. . . . . . . . . . . . . . . . . . . . . vii . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 137 140 141 143 147 148 150 159 159 160

10 Scoring data with predictive models 162 Building a predictive model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 Evaluating the model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 Applying the model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 Part II: Programming with Python 11 Introduction 167 12 Getting Started with Python Programming in IBM SPSS Statistics 170 The spss Python Module. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 Running Your Code from a Python IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 The SpssClient Python Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 Submitting Commands to IBM SPSS Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 Dynamically Creating Command Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 Capturing and Accessing Output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 Modifying Pivot Table Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 Python Syntax Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 Mixing Command Syntax and Program Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 Nested Program Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 Handling Errors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 Working with Multiple Versions of IBM SPSS Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 Creating a Graphical User Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 Supplementary Python Modules for Use with IBM SPSS Statistics . . . . . . . . . . . . . . . . . . . . . . . 192 Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 13 Best Practices 194 Creating Blocks of Command Syntax within Program Blocks. . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 Dynamically Specifying Command Syntax Using String Substitution . . . . . . . . . . . . . . . . . . . . . . 195 Using Raw Strings in Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 Displaying Command Syntax Generated by Program Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 viii

Creating User-Defined Functions in Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Creating a File Handle to the IBM SPSS Statistics Install Directory . . . . . . . . . . . . . . . . . . . . . . . 199 Choosing the Best Programming Technology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 Using Exception Handling in Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 Debugging Python Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 14 Working with Dictionary Information 207 Summarizing Variables by Measurement Level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 Listing Variables of a Specified Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 Checking If a Variable Exists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 Creating Separate Lists of Numeric and String Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 Retrieving Definitions of User-Missing Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 Identifying Variables without Value Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 Identifying Variables with Custom Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 Retrieving Datafile Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 Retrieving Multiple Response Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 Using Object-Oriented Methods for Retrieving Dictionary Information. . . . . . . . . . . . . . . . . . . . . 219 Getting Started with the VariableDict Class . . . . . . . . Defining a List of Variables between Two Variables . . Specifying Variable Lists with TO and ALL . . . . . . . . . Identifying Variables without Value Labels . . . . . . . . . Using Regular Expressions to Select Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Working with Case Data in the Active Dataset . . . . . 219 222 222 223 224 226 Using the Cursor Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 Reading Case Data with the Cursor Class. . . . . . . . . . . . . Creating New Variables with the Cursor Class . . . . . . . . . Appending New Cases with the Cursor Class. . . . . . . . . . Example: Counting Distinct Values Across Variables . . . . Example: Adding Group Percentile Values to a Dataset . . Using the spssdata Module. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 233 234 235 236 238 Reading Case Data with the Spssdata Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating New Variables with the Spssdata Class . . . . . . . . . . . . . . . . . . . . . . . . . Appending New Cases with the Spssdata Class. . . . . . . . . . . . . . . . . . . . . . . . . . Example: Adding Group Percentile Values to a Dataset with the Spssdata Class . Example: Generating Simulated Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 244 249 250 251 ix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

16 Creating and Accessing Multiple Datasets 254 Getting Started with the Dataset Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 Accessing, Adding, or Deleting Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 Retrieving, Modifying, Adding, or Deleting Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 Example: Creating and Saving Datasets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 Example: Merging Existing Datasets into a New Dataset. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 Example: Modifying Case Values Utilizing a Regular Expression . . . . . . . . . . . . . . . . . . . . . . . . . 265 Example: Displaying Value Labels as Cases in a New Dataset. . . . . . . . . . . . . . . . . . . . . . . . . . . 267 17 Retrieving Output from Syntax Commands 271 Getting Started with the XML Workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 Writing XML Workspace Contents to a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 Using the spssaux Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 282 18 Creating Procedures Getting Started with Procedures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282 Procedures with Multiple Data Passes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 Creating Pivot Table Output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 Treating Categories or Cells as Variable Names or Values . . . . . . . . . . . . . . . . . . . . . . . . . . 291 Specifying Formatting for Numeric Cell Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 19 Data Transformations 295 Getting Started with the trans Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 Using Functions from the extendedTransforms Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 The search and subs Functions . . The templatesub Function . . . . . . The levenshteindistance Function The soundex and nysiis Functions The strtodatetime Function . . . . . The datetimetostr Function . . . . . The lookup Function. . . . . . . . . . . . . . . . . . . . . . . . . x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 302 304 305 306 307 307

20 Modifying and Exporting Output Items 309 Modifying Pivot Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 Exporting Output Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310 21 Tips on Migrating Command Syntax and Macro Jobs to Python 315 Migrating Command Syntax Jobs to Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 Migrating Macros to Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 321 22 Special Topics Using Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 Locale Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323 Part III: Programming with R 23 Introduction 327 24 Getting Started with R Program Blocks 328 R Syntax Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330 Mixing Command Syntax and R Program Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332 Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 25 Retrieving Variable Dictionary Information 334 Retrieving Definitions of User-Missing Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335 Identifying Variables without Value Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 Identifying Variables with Custom Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338 Retrieving Datafile Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338 Retrieving Multiple Response Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339 xi

26 Reading Case Data from IBM SPSS Statistics 341 Using the spssdata.GetDataFromSPSS Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341 Missing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 Handling IBM SPSS Statistics Datetime Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344 Handling Data with Splits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344 Working with Categorical Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346 27 Writing Results to a New IBM SP

functions with users of SPSS Statistics command syntax. SPSS Statistics for SAS programmers. For readers who may be more familiar with the commands in the SAS system, Chapter 32 provides examples that demonstrate how some common data management and programming tasks are handled in both SAS and SPSS Statistics. Using This Book

Related Documents:

Bruksanvisning för bilstereo . Bruksanvisning for bilstereo . Instrukcja obsługi samochodowego odtwarzacza stereo . Operating Instructions for Car Stereo . 610-104 . SV . Bruksanvisning i original

10 tips och tricks för att lyckas med ert sap-projekt 20 SAPSANYTT 2/2015 De flesta projektledare känner säkert till Cobb’s paradox. Martin Cobb verkade som CIO för sekretariatet för Treasury Board of Canada 1995 då han ställde frågan

service i Norge och Finland drivs inom ramen för ett enskilt företag (NRK. 1 och Yleisradio), fin ns det i Sverige tre: Ett för tv (Sveriges Television , SVT ), ett för radio (Sveriges Radio , SR ) och ett för utbildnings program (Sveriges Utbildningsradio, UR, vilket till följd av sin begränsade storlek inte återfinns bland de 25 största

Hotell För hotell anges de tre klasserna A/B, C och D. Det betyder att den "normala" standarden C är acceptabel men att motiven för en högre standard är starka. Ljudklass C motsvarar de tidigare normkraven för hotell, ljudklass A/B motsvarar kraven för moderna hotell med hög standard och ljudklass D kan användas vid

LÄS NOGGRANT FÖLJANDE VILLKOR FÖR APPLE DEVELOPER PROGRAM LICENCE . Apple Developer Program License Agreement Syfte Du vill använda Apple-mjukvara (enligt definitionen nedan) för att utveckla en eller flera Applikationer (enligt definitionen nedan) för Apple-märkta produkter. . Applikationer som utvecklas för iOS-produkter, Apple .

This presentation and SAP's strategy and possible future developments are subject to change and may be changed by SAP at any time for any reason without notice. This document is 7 provided without a warranty of any kind, either express or implied, including but not limited to, the implied warranties of merchantability, fitness for a .

och krav. Maskinerna skriver ut upp till fyra tum breda etiketter med direkt termoteknik och termotransferteknik och är lämpliga för en lång rad användningsområden på vertikala marknader. TD-seriens professionella etikettskrivare för . skrivbordet. Brothers nya avancerade 4-tums etikettskrivare för skrivbordet är effektiva och enkla att

Den kanadensiska språkvetaren Jim Cummins har visat i sin forskning från år 1979 att det kan ta 1 till 3 år för att lära sig ett vardagsspråk och mellan 5 till 7 år för att behärska ett akademiskt språk.4 Han införde två begrepp för att beskriva elevernas språkliga kompetens: BI