Convert Numeric to Date Variable

Summary For time calculations (such as the number of days between two dates) proper date variables are needed. In some cases, the digits of a numeric variable may represent year, month and day. This tutorial shows how to convert this format into an actual date variable. Convert Numbers to SPSS Date Variables In some cases, […]

SPSS RANGE Function – Quick Tutorial

COMPUTE v2 = RANGE(V1,2,4). SPSS RANGE Function Result Summary SPSS’ RANGE function is used to evaluate whether or not values are within a given range. Test values equal to the lower or upper boundary are also within the given range. Run the syntax below for a quick demonstration. SPSS Range Syntax Example *1. Create couple of cases. data list free/v1(f1). begin […]

SPSS Date Variables Basics

SPSS date variables may seem a bit puzzling at first. However, getting things done fast and accurately with SPSS date variables is not hard at all if you understand some basics. This tutorial will walk you through. You can follow along by downloading and opening hospital.sav. SPSS Date Variables – What Are They? First of all, […]

Date Variables

In SPSS, a date is the number of seconds since the year 1582. These are huge numbers but they are still just numbers like somebody’s weight in kilos or the number of cars in some household. The main difference between dates and other variables is that SPSS displays dates with slashes or dots as in “2016/11/07”. Once you fully realize […]

Disaggregate Data

Introduction Sometimes, one may start a project with aggregated data, weighted by a frequency variable. In some cases, though, disaggregating such data (creating n rows for a row with frequency n) may be desired. SPSS Syntax Example *1. Create test data. data list free/gender employed frequency. begin data 0 0 5 1 0 2 0 1 8 1 […]

SPSS VARSTOCASES With Labels Tool

Running VARSTOCASES is often necessary for generating nice charts in SPSS. One of the many examples is a stacked bar chart for comparing multiple variables. Sadly, we lose our variable labels when running VARSTOCASES and we really do need those. The solution is a simple tool that generates our VARSTOCASES for us and applies the variable labels of the input variables as value […]

Restructuring Data in SPSS – Overview

SPSS offers several simple ways for restructuring data. VARSTOCASES -short for “variables to cases”- stacks variables on top of each other. Its reverse is CASESTOVARS -short for “cases to variables”. It basically stacks groups of cases behind each other in new variables. AGGREGATE adds summary statistics such as frequencies, sums and means to your data, optionally collapsing cases in the process. […]

Merging Data Files in SPSS

For merging SPSS data files with similar cases but different variables, use MATCH FILES. Make sure your case identifier -if any- doesn’t contain duplicate values and the files are sorted ascendingly on it. The result contains all cases from both files (like a full outer join in SQL).Second, MATCH FILES also performs a table lookup as illustrated below. SPSS […]

String Variables

String variables are variables that hold zero or more characters such as letters, numbers, spaces, commas and many more. You can’t use numeric functions such as addition or subtraction on string variables. You can, however, extract one or more characters (a substring) from them, glue them together (concatenate) and a couple of other functions. Like so, working […]

SPSS – Merge Categories of Categorical Variable

Summary Merging some categories of a categorical variable in SPSS is not hard if you do it the right way. This tutorial demonstrates just that. We recommend you try the examples for yourself by downloading and opening hotel_evaluation.sav. Right, when doing a routine inspection of this data file, we’ll see that the variable nation has many small categories. This becomes apparent when […]

Recoding Variables in SPSS

Recoding both string and numeric variables in SPSS is usually done with RECODE. Doing so with syntax is way faster than with the menu, especially if you want to recode many variables at once. Note that you’ll often want to apply or adjust some value labels after recoding.Alternatively, string variables can be recoded into numeric variables with AUTORECODE. Doing […]

SPSS Scratch Variables

Definition Scratch variables are temporary helper variables that don’t show up in your data. A variable is a scratch variable if (and only if) its name starts with “#”. SPSS Scratch Variable – Introduction Say we have a data file holding phone numbers. Now we’d like to extract the area codes into a separate variable. […]

SPSS DO REPEAT – Simple Tutorial & Examples

DO REPEAT is a command for running other commands repetitively.SPSS DO REPEAT is often used for looping over (possibly new) variables. VECTOR with LOOP is an alternative way for doing so. Introduction Suppose we have a variable containing values 1 through 4 and we’d like to dichotomize it for a regression analysis. (For some more background, see Creating Dummy Variables in SPSS.) […]

SPSS Looping Tutorials

SPSS DO REPEAT – Simple Tutorial & Examples SPSS LOOP – Quick Tutorial & Examples SPSS VECTOR – Quick Tutorial  

Read and Merge Multiple Sheet Excel Workbooks

Summary Reading multiple sheet Excel workbooks into SPSS is easily done with this Custom Dialog. This tutorial demonstrates how to use it. Before You Start SPSS Read and Merge Excel Files Tool Make sure you have the SPSS Python Essentials installed. Download and install the xlrd module. If you’d like to generate some test data as done in […]

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” […]

SPSS ADD FILES Command

Summary ADD FILES is an SPSS command that’s mainly used for merging data sources holding similar variables but different cases. (For the same cases but different variables, see MATCH FILES.) A second use is for reordering and/or dropping variables in a single dataset. SPSS Add Files Matches Data Sources on Variable Names SPSS Add Files – Basic Usage The ADD FILES command […]

Regression over Many Dependent Variables

“I have a data file on which I’d like to carry out several regression analyses. I have four dependent variables, v1 through v4. The independent variables (v5 through v14) are the same for all analyses. How can I carry out these four analyses in an efficient way that would also work for 100 dependent variables?” […]

Search Syntax Files for Expression

Question “I found a variable “v_4” in an old data file and I can’t remember how exactly I created it. The syntax I used got a bit messy, I have different files and they’re in different folders. Is there an easy way to find out which syntax files contain the expression “v_4″?” SPSS Search Syntax […]

Move all Files from Subfolders to Main Folder

Question “I’d like to work with a number of .sav files but they are scattered over different folders. All file names are unique. Is there any easy way to search through a number of folders for .sav files and move these into some root directory?” SPSS Python Syntax Example *1. Create random test folders and […]