Back to stats page
SPSS Syntax files etc
Download Problems. The good folks at Angelfire/Lycos have introduced some 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 will probably open the .txt file directly, and you may then either copy and paste into an SPSS syntax window, or Save-As and change the extension to .SPS.
SPSS Tutorials
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, Douglas.)
- 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 procedure.
- 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 procedure.
- 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 versa).
Syntax files demonstrating how to accomplish various tasks
- ANOVA, ANCOVA, and GLM
- anova1.txt: Examples of one-way ANOVA.
- anova2.txt: Examples of two-way ANOVA, including: [1] analysis of simple main effects using EMMEANS with COMPARE in GLM UNIANOVA, and using MANOVA syntax; [2] a mixed effects model with one random and one fixed factor.
- change_scores_and_ANCOVA.txt: 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.
- repmeas_ANOVA_with_long_file.SPS: 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 time-dependent covariates.
- varcomp_examples.txt: How to compute variance components for two common designs.
- Categorical data
- association.txt: Chi-square test of association.
- fisher.txt: Examples of Fisher's exact test.
- goodfit.txt: Chi-square goodness of fit test.
- mcnemar.txt: McNemar chi-square, aka McNemar "change" test.
- phikappa.txt: Examples of phi-coefficient and Cohen's kappa.
- 2x2.txt: 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 for binomial proportions
- ciprop.txt: Confidence intervals for a binomial proportion. Uses 3 different methods:
- Inverse beta function
- Wilson score/Ghosh (1979) method (these are identical).
- clopper_pearson.txt: Calculates Clopper-Pearson "exact" confidence interval for a binomial proportion.
- 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.
- Importing Data
- 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
- logistic1.txt: 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.
- Macros
- SLR_macro.txt: A macro that demonstrates how to peform a series of simple linear regressions, all with the same outcome variable (Y).
- SLR_macro_v2.txt: 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.
- regression_with_matrix_input.txt: 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 one.
- convert_macro.txt: 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.
- macro_with_nested_loop.txt: 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.
- power_analysis_part2.txt: 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.
- Meta-analysis
- 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
- power_analysis.txt: 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
- Utilities
- 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.
- 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.
- median_across_columns.txt: 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.
- number_records.txt: 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.
- Z-scores
- z_scores.txt: Calculates standard scores (i.e., Z-scores) and saves them to the working data file (using /SAVE option of the DESCRIPTIVES command).
Miscellaneous