Download Problems. Some of the files available for download on this page are still stored on my old Angelfire/Lycos website. Some time ago, Angelfire/Lycos made changes that may affect access to files of various
non-standard types, like SPSS syntax files, for example. To simplify
matters, I have changed the extensions on most of my syntax files from
.SPS to .txt. Your browser may open the .txt file directly. If so, you can then either copy and paste into an SPSS syntax window, or
Save-As and change the extension to .SPS.
The tutorials listed below are stored in .zip files. You will need a
zip-file utility (such as WinZip) to open them. If you don't already
have such a utility, you can no doubt find several free ones at sites
such as download.com.com. I use PowerArchiver. A couple others are listed on my Programming & Software page
(near the bottom of the page). Many thanks to Dr. Douglas Murphy for
working through the first draft of these tutorials and finding spots
where my instructions were unclear. (Och...you're a grrrea' man,
Syntax files demonstrating how to accomplish various tasks
- Tutorial 1.
How to: Import data from Excel; create some simple graphs; obtain
descriptive statistics; transform data (COMPUTE, RECODE). This tutorial
also emphasizes the value of using PASTE rather than OKAY.
- Tutorial 2.
How to: Create some more graphs; create grouped frequency distributions
& histograms; use the DATA LIST command to read in data. Bare Essentials refers to the book Biostatistics: The Bare Essentials (2nd Ed, ISBN 1-5509-123-9).
- Tutorial 3.
How to: Do basic arithmetic operations (addition, subtraction,
multiplication, division, squaring, square roots); obtain the sum of a
column of numbers; compute means using these basic tools.
- Tutorial 4.
How to: Calculate the mean, variance and standard deviation (SD) using
the conceuptal formula, but using SPSS (instead of a calculator) to do
the calculations; calculate the mean, variance and SD using the MEANS
- Tutorial 5.
How to: Calculate standard scores (aka z-scores) using the conceptual
formula, but using SPSS (instead of a calculator) to do the
calculations; calculate standard scores using the DESCRIPTIVES
- Tutorial 6. A demonstration of the central limit theorem (CLT) using a small population of 5 scores and all possible samples of n=2.
- Tutorial 7.
How to: compute AGE from date of birth and another date variable; merge
files (add variables, and add cases); flag the First and Last records
in a group of records; to combine data across records using the
AGGREGATE command; restructure a data file (from WIDE to LONG and vice
- ANOVA, ANCOVA, and GLM
- anova1.txt: Examples of one-way ANOVA.
Examples of two-way ANOVA, including:  analysis of simple main
effects using EMMEANS with COMPARE in GLM UNIANOVA, and using MANOVA
syntax;  a mixed effects model with one random and one fixed factor.
Performs ANCOVA with GROUP as a between-Ss factor, Pre-Test as the
covariate, and either Post-Test or CHANGE as the dependent variable. It
is commonly held that the first of these models (with post-test as the
DV) is correct, and the second incorrect. However, as demonstrated by
this syntax file, the coefficients and F-tests for group in these two
models are identical.
Shows how to perform repeated measures ANOVA using GLM UNIANOVA with a
LONG file format (i.e., data file has multiple rows per subject). The
more common approach is to use GLM REPEATED MEASURES on a WIDE file
(i.e., one row per S with multiple columns for the outcomes). There are
some advangages to using the LONG file and UNIANOVA approach. For
example, if a S has one or more missing data points, they are excluded
entirely in the GLM REPEATED MEAUSRES analysis. But not so in the
UNIANOVA approach: Whatever valid data points they have are included in
the analysis. (If all subjects have complete data, the two methods
yield the same F-test.) The LONG file format also allows one to include
- varcomp_examples.txt: How to compute variance components for two common designs.
- Categorical data
- Chi-square tests
- fisher.txt: Examples of Fisher's exact test.
- phikappa.txt: Examples of phi-coefficient and Cohen's kappa.
Calculates various statistics for 2x2 tables (Pearson chi-square,
chi-square with Yates' correction, likelihood ratio chi-square,
relative risk, odds ratio). [NOTE: The current version of this
file is dated 18-Feb-2003. The earlier version has an error in the
computation of the variance of ln(RR), so please replace it with this
one. My apologies for any inconvenience this may have caused.]
- Confidence intervals
- CIs for binomial proportions
- ciprop.SPS: Confidence intervals for a binomial proportion. Uses 5 different methods:
- 1. Clopper-Pearson "exact" method.
- 2. Wald method (i.e., the usual normal approximation) .
- 3. Adjusted Wald method (using z**2/2 and z**2 rather than 2 and 4).
- 4. Wilson score method (from Newcombe's paper).
- 5. Jeffreys method (http://www-01.ibm.com/support/docview.wss?uid=swg21474963).
- ciprop2.SPS: Allows the user to choose which of 5 methods to use for each row of input data.
- CIs for rho, the parameter corresponding to Pearson's r.
- DO REPEAT examples
- Example 1: Uses a DO REPEAT loop to flag a series of items as correct or incorrect.
- Example 2: Uses a DO REPEAT loop to compute a new series of variables.
- Example 3: A long DO-IF-ELSE-IF structure is replaced with a fairly simple DO-REPEAT.
- Importing Data
- read data from mixed files: Some examples of how to read data from a file with different types of records in it.
- Importing date variables from Excel:
- Linear regression examples
- linreg.txt: Linear regression examples.
- linreg_using_subset.txt: How to perform linear regression using only a subset of cases, but save predicted scores for ALL cases in the file.
- See the Macros section below for examples of how to run a series of simple linear regressions (aka univariate regressions) using macros.
- Logistic Regression & NOMREG
Simple logistic regression examples. Shows that the "change in -2 log
likelihood" chi-square test from logistic regression is identical to
the likelihood ratio chi-square from CROSSTABS.
- pooling_odds_ratios.txt. Shows how to pool odds ratios using Cochran-Mantel-Haenszel method, and using logistic regression.
- NOMREG_TEST_Example.sps: An example showing how to use NOMREG with TEST sub-commands to get a test (and CI) for the ratio of two odds ratios.
- CIs for rho, the parameter corresponding to Pearson's r.
- Supplementary material for my Behavior Research Methods article describing the !OLScomp and !MLEcomp macros.
- Recursion with macros. This thread from the SPSSX-L mailing list has some amazing examples of what can be done with recursive macros.
- SLR_macro.txt: A macro that demonstrates how to perform a series of simple linear regressions, all with the same outcome variable (Y).
An improved version of the previous macro that does not require one to
rename the predictor variables to X1, X2, X3, etc. Thanks to Neila
Nessa (aka David Marso) for the help on this one.
Here is yet another way to accomplish the same task using a correlation
matrix output from the CORRELATIONS procedure as input for the
REGRESSION procedure. This one is recommended if you have a large
number of cases, because the correlation matrix is computed only once,
which will save a lot of time. Thanks again to Neila Nessa for this
A macro that allows the user to change the format of a list of
variables from string to numeric or vice versa. This is a modification
of a macro found on Raynald Levesque's SPSS Tools website.
A macro that contains a nested loop, in which the starting value for
the inner loop is equal to the current value of the outer loop plus 1.
The macro language cannot do arithmetic, so getting this to work
requires a bit of trickery, which I borrowed from one of the examples
listed on Raynald Levesque's SPSS Tools website.
A macro by David Marso that does power calculations on simulated data.
This file is also listed under the Power & Sample Size heading
below. It is included here in the Macro section because it demonstrates
a lot of interesting features of the macro language.
- Matrix language
- matrix001.txt: Demonstrates matrix algebra basics using SPSS Matrix Language.
- matrix002.txt: Uses SPSS Matrix Language to solve system of simultaneous linear equations.
- matrix003.txt: Uses SPSS Matrix Language to solve a multiple regression equation.
- fleiss.txt: Performs meta-analysis using a general method described by Fleiss (1993). Download a stand-alone Turbo Pascal program that implements the same method.
- MIXED procedure examples
- mixed001.txt: How to perform one-way ANOVA with the MIXED procedure.
- mixed002.txt: How to perform two-way ANOVA with the MIXED procedure.
- mixed003.txt: How to perform one-factor repeated measures ANOVA with the MIXED procedure.
- mixed004.txt: How to perform simple linear regression with the MIXED procedure.
- mixed005.txt: How to perform one-way ANCOVA with the MIXED procedure.
- mixed006.txt: How to perform multiple regression with the MIXED procedure.
- mixed007.txt: How to perform split-plot (between-within) ANOVA with the MIXED procedure.
- Output Management System (OMS)
- Power analysis and sample size estimation
Examples of power analysis for multivariate and repeated measures
designs (from the D'Amico, Neilands, & Zambarano paper in Behavior
Research Methods, Instruments, & Computers 2001, 33(4), 479-484). But
note that there may be some serious problems with using "observed
power" from SPSS MANOVA or GLM procedures as the basis for sample size
estimation, as discussed in this newsgroup thread.
- Probability distributions
- binomial.txt: Syntax to generate binomial distributions. User must specify N and p by altering two lines near the top of the file.
- plot_t_distributions.txt: Plot t-distributions with varying degrees of freedom (and the standard normal distribution).
- Rank-based tests
- nonpar.txt: Examples of 3 common nonparametric tests (Sign test, Wilcoxon signed ranks, and Mann-Whitney U).
- Restructuring the data
- restructure.txt: Demonstrates how to restructure the data file using CasesToVars and VarsToCases. These file restructure commands are only available in SPSS 11 or later.
- restructure_old.txt: The old fashioned way, for those who are running older versions of SPSS.
- Sampling Distribution Demonstration
- age.txt: How to compute AGE from date of birth (DOB) and another date. Here is another file in which Art Kendall shows 3 ways to compute age to the nearest year. One of Art's methods is the one I used in my file.
- any_demo.txt: Shows two different ways to use the ANY function.
- Covariance_matrix: Shows a couple methods for creating a covariance matrix.
- Delete_rows_with_all_missing.txt: Delete rows (or cases) where all numeric variables are missing and all string variables contain only blanks. This syntax arose out of an interesting thread from the SPSSX-L mailing list. David Marso posted the original syntax; I then tweaked it a bit to make it more general; and then I tweaked it again after seeing Albert-Jan Ros's nice use of the keyword ALL for looping through all variables in a file.
- double_entry_check.txt: An example of how to check double-entered data for consistency.
- find_duplicate_records.txt: Find and remove duplicate records in a data file.
- flag last day of month.txt: Use DATE.DMY to flag records with date equal to the date of the last day of the month.
SPSS has no function for computing the median across columns. One
work-around solution is to restructure the file from WIDE to LONG
(using VarsToCases), then use AGGREGATE to get the median.
- min_and_max.txt: Examples of how to obtain MINIMUM and MAXIMUM scores (both overall, and within groups) using SCRATCH variables.
Shows how to number the records (for files where each unique ID can
have more than 1 record), and how to record the total number of records
per ID on each row with that ID.
- random_sample.txt: Shows how to randomly sample X of N cases.
- scratch1.txt: Example that shows how scratch variables maintain their value from case to case.
Calculates standard scores (i.e., Z-scores) and saves them to the
working data file (using /SAVE option of the DESCRIPTIVES command).