Compare Dictionaries over Files Before Merging

Introduction Merging data with ADD FILES can result in nonsensical data. This occurs when variables or values have different meanings over files. By comparing dictionaries over files, inconsistently coded variables are quickly detected. So What’s the Problem? When files are merged with ADD FILES, inconsistent dictionary information is discarded. This will happen, for example, if a variable v1 means “gender” […]

Python Xlrd (Excel Read) Module

xlrd is a module that allows Python to read data from Excel files. This tutorial explains where to get it and how to install it. Downloading the Python Xlrd Module The Python xlrd (short for “Excel Read”) module can be found here. After downloading it, you can extract the contents (twice) with 7 Zip. Copy the path of the folder that […]

SPSS – Change Value Labels with Python

A local supermarket held a small survey, the data of which are in minisurvey.sav. Unfortunately, the software for downloading the data in SPSS format prefixes all variable and value labels with the variable names. The screenshot below shows part of the data. Undesired Prefixes in Value Labels Clicking on some value labels in variable view confirms that they’ve […]

SPSS – Create Several Excel Files with Python

A teacher held a course evaluation. The data in SPSS format are in course_evaluation.sav, part of which is shown below. Students from different majors participated and now the education director wants separate Excel files for each major. A super easy way for creating these is by using SPSS with Python. We’ll walk you through. 1. Save SPSS Data as […]

SPSS – Batch Process Files with Python

Running syntax over several SPSS data files in one go is fairly easy. If we use SPSS with Python we don’t even have to type in the file names. The Python os (for operating system) module will do it for us. Try it for yourself by downloading spssfiles.zip. Unzip these files into d:\spssfiles as shown below and you’re good to go. Find All Files […]

SPSS Python Examples

Learn Python for SPSS the right way by running some of the examples below. They show precisely how to get things done in SPSS the fastest way possible and are easily modified to suit your needs. Enjoy! Latest SPSS Python Examples Batch Process Files with Python Create Several Excel Files with Python Change Value Labels with Python SPSS with […]

SPSS Python Text Replacement Tutorial

A common task in Python is building strings from other strings, especially if we’re creating SPSS syntax. We could simply concatenate strings into larger strings but there’s a nicer way: string replacements with the % sign. Please note that the examples in this tutorial assume Python2.x* and may not run in Python3.x. Python String Replacement with %s *Replace […]

SPSS Python String Tutorial

The most important Python object we’ll deal with are strings. This tutorial presents a quick overview of Python string methods. However, let’s first learn some very basics. Python Strings – Basic Rules Strings may be enclosed by single or double quotes if they don’t contain any line breaks; Strings may always be enclosed by 3 single […]

Python – The 5 Things You Want to Know

SPSS users who want to speed up their work by using Python will encounter some surprises. This tutorial walks you through the 5 major pitfalls and shows how to avoid them. 1. Python is Fully Case Sensitive SPSS is mostly case insensitive; if we have a variable “gender”, we can address it in syntax as gender or GENDER or anything in between. […]

SPSS with Python IV – How to Use It?

So how does Python for SPSS actually work? First off, a distinction is often made between SPSS Python programmability and SPSS Python scripting. They work similarly in that some Python code is included in SPSS syntax; SPSS passes this Python code on to Python; Python may then look up information in SPSS such as variable names in the dataset or tables in the output window; […]

SPSS with Python III – How Does It Work?

So how does Python for SPSS actually work? First off, a distinction is often made between SPSS Python programmability and SPSS Python scripting. They work similarly in that some Python code is included in SPSS syntax; SPSS passes this Python code on to Python; Python may then look up information in SPSS such as variable names in the dataset or tables in the output window; […]

Python for SPSS

Python is a programming language that can be integrated with SPSS versions 14 and higher. By using Python in SPSS you can automate basically any SPSS task such as batch processing data files or output tables and charts. Recent SPSS versions allow you to add SPSS extensions similarly to apps on a smartphone. Most extensions can be used from […]

SPSS with Python I – What is It?

Python is among the most important programming languages today and can be used in SPSS. Doing so may truly decimate the time and effort you need to get things done. This tutorial briefly explains what Python is, how it relates to SPSS and why you might want to start using it. What is Python? Python is among the most important […]

SPSS with Python II – Installing and Testing

We think SPSS with Python is great! However, you need to have the SPSS Python Essentials properly installed in order to use it. This tutorial gives a quick overview of installing and then testing them for different SPSS versions. SPSS Python Essentials The basic components you need for running Python in SPSS are SPSS; Python; the SPSS Python plugin. […]