SPSS INDEX Function

Summary The SPSS INDEX function returns the position of the first occurrence of a given expression within a string. If the expression does not occur in the string, it returns a zero. As a rule of thumb, always use it as CHAR.INDEX. The reason for this is explained SPSS Unicode Mode. Note that string values are case sensitive. SPSS Index […]

SPSS Missing Values Functions

Most real world data contain some (or many) missing values. It’s always a good idea to inspect the amount of missingness for avoiding unpleasant surprises later on. In order to do so, SPSS has some missing values functions that are mostly used with COMPUTE, IF AND DO IF. This tutorial demonstrates how to use them effectively. We’ll do so […]

SPSS AUTORECODE Command

SPSS AUTORECODE – Minimal Example autorecode str_var1 str_var2 str_var3 /into num_var1 num_var2 num_var3. Introduction This tutorial explains SPSS’ AUTORECODE command and shows how to use it properly on nominal_strings.sav, a screenshot of which is shown below. We recommend downloading this data file and following along with the steps in this tutorial. SPSS AUTORECODE – What Is It? […]

Computing Variables in SPSS – Overview

Computing new variables -often as means or sums over other variables- is usually done with COMPUTE. If you want to do so for only some cases but not others, use IF instead. Some alternatives for creating new variables in SPSS are RECODE, AUTORECODE, AGGREGATE and RANK. Computing Variables Tutorials SPSS Missing Values Functions SPSS COMPUTE – Simple Tutorial

SPSS Clone Variables Tool

In SPSS, I don’t like to recode variables into new variables: the new variables don’t have any dictionary information such as variable/value labels or formats. Second, a recoded variable is appended to the end of the file but I rather have it in its original position. Both problems are avoided by recoding into the same variables. However, […]

SPSS VARSTOCASES – What and Why?

SPSS VARSTOCASES is short for “variables to cases”. It restructures data by stacking variables on top of each other as illustrated by the figure above. You can try this simple example for yourself by downloading and opening sav_data018 and running the syntax below on it. SPSS VARSTOCASES Example 1 *Very basic VARSTOCASES example. varstocases /make v from […]

SPSS Recode Values with Value Labels

Introduction In SPSS we sometimes find ordinal variables where lower values indicate more positive attitudes or larger quantities. An example is shown in the screenshot below. Now, the coding scheme shown above is not really ‘wrong’ in any way. However, we usually prefer higher values indicating more positive attitudes or larger quantities because we find this more […]

SPSS MATCH FILES Command

MATCH FILES is an SPSS command mostly used for merging data holding similar cases but different variables. For different cases but similar variables, use ADD FILES. MATCH FILES is also the way to go for a table lookup similar to VLOOKUP in Excel. Merging two datasets by id, which is a unique case identifier. SPSS Match Files – Basic Use The […]

SPSS COMPUTE – Simple Tutorial

SPSS COMPUTE command sets the data values for (possibly new) numeric variables and string variables. These values are usually a function (such as MEAN, SUM or something more advanced) of other variables. This tutorial walks you through doing just that. We’ll use hospital.sav,a screenshot of which is shown below. Before proceeding, we’ll first set 6 as a user missing value for the last 5 […]

SPSS AGGREGATE Command

Aggregate is an SPSS command for creating variables holding statistics over cases. This tutorials briefly demonstrates the most common scenarios and points out some best practices. SPSS Aggregate Command The SPSS AGGREGATE command typically works like so: One or more BREAK variables can be specified.* All cases with the same value(s) on the break variable(s) are referred to as a break group Each […]

SPSS – Convert String into Date Variable

For converting string variables to date variables, ALTER TYPE is the way to go. This tutorial demonstrates how to do this and points out a couple of caveats. For those who can’t use ALTER TYPE, we’ll propose some alternatives. SPSS Alter Type The syntax below first creates a mini dataset holding 8 string variables. They demonstrate the 8 most common date formats. Next, […]

SPSS Datetime Variables Basics

Introduction Working with SPSS datetime variables is not hard at all if you understand some basics. This tutorial walks you through just those. Those who’d like to follow along may download and open hospital.sav. SPSS Datetime Variables – What Are They? SPSS datetime variables are variables that hold the numbers of seconds between the year 1582 and […]

SPSS Time Variables Basics

Introduction Working efficiently with SPSS time variables is not hard if you understand some basics. This tutorial walks you through just those. We recommend you follow along by downloading and opening hospital.sav. SPSS Time Variables – What Are They? SPSS time variables are variables that hold time intervals in numbers of seconds. Although the actual time values […]

SPSS String Variables Basics

For working proficiently with SPSS string variables , it greatly helps to understand some string basics. This tutorial explains what SPSS string variables are and demonstrates their main properties. We encourage you along by downloading and opening string_basics.sav. The syntax we use can be copy-pasted or downloaded here. SPSS String Variables – What Are They? String variables are one […]

SPSS Date Variables Tutorial

SPSS date calculations are much easier than they may seem at first. The first key to success is understanding what SPSS date variables really are. Next, choose (and possibly combine) the right date functions. This tutorial will walk you through the main ones. We recommend you follow along by downloading and opening hospital.sav. SPSS Main Date Functions The table […]

SPSS String Variables Tutorial

Working with string variables in SPSS is pretty straightforward if one masters some basic string functions. This tutorial will quickly walk you through the important ones. SPSS Main String Functions CHAR.SUBSTR (substring) – Extract character(s) from string CONCAT (concatenate) – Combine strings CHAR.INDEX – Find first occurrence of character(s) in string CHAR.RINDEX (right index) – Find last occurrence of character(s) in […]