SPSS macro performs K-means Cluster analysis and does the “heavy lifting”

SPSS macroI frequently play around with multivariate techniques like K-means cluster analysis in SPSS.  There were some big holes in the SPSS procedure that performs cluster analysis so wrote an SPSS Macro to automate what I wanted to be done.    Below is a  quick demo of the macro in use. It can really save a bunch of time!  A few things mine does differently is:

  1. assigns labels to the segments (these will be changed later but butter than just a 1,2,3)
  2. Computes frequencies on the size of the segments (Why SPSS doesn’t do this automatically is beyond me)
  3. Color-codes and merges the significance testing in with the profile-plot showing what is different.

SPSS macro performing K-means Cluster analysis

K-means Cluster Macro


Automating the creation of randomly split-out text files with an SPSS macro

SPSS macro

I frequently need to randomize my lists and save them into separate text files. This SPSS macro makes it a breeze!

If you haven’t already played with macros you’ll want to get yourself familiar with them by reviewing this post on Intro to Macros.  The macro will need a few parameters from you like: the path to save the files, Stem (beginning) name of the files to create, # of groups to create and whether or not to keep the variable used to create the groups.

Automating the creation of randomly split-out text files

Below is the SPSS Macro which will automate the process.

Remember to define the SPSS macro before calling it!.

SPSS Macro is just a String Parser, this video goes over some basic usage

SPSS macro

Even in its simplest form, SPSS macros can save you an amazing amount of time by allowing you to quickly & easily swap-out one text for another. The text can be the name of a variable, the title, the statistical test to be run, etc. This can save an amazing amount of time if used properly.

In the below video gives a good demonstration of how easy it is to utilize them.

SPSS Macro is just a String Parser

SPSS Macro is just a String Parser

SPSS Macros for replacing missing data

SPSS macro

SPSS Macros for replacing missing data

A lot of online vendor tools provide a data value on a multi-select question however they leave the value missing if the respondent didn’t select it. Most of the analysis I want to do needs to have a zero (or some other value) present in order to calculate the statistics correctly.

I wrote a few SPSS Macros that make it very easy to replace the missing values on your data.  Here are the two macros


SPSS Macros- Replacing missing data