You are on page 1of 8

3/12/2014 SPSS, SAS, and Mplus Macros and Code - Andrew F. Hayes, Ph.D.

http://www.afhayes.com/spss-sas-and-mplus-macros-and-code.html 1/8
Andrew F. Hayes, Ph.D.
893 people recommend this. Sign Up to see what your f riends
recommend.
Recommend

Tweet 40
Now registering for my May 2014 and July 2014
moderation and mediation analysis courses
PROCESS can be found on the web page for
My Macros and Code for SPSS and SAS
On this page you will find information about many of
the macros for SPSS and SAS that I have written.
Most of these are described in various publications, and
I recommend you read the corresponding publication
before using the macro.
DISCLAIMER: As with all statistical software, all
attempts are made to make sure that the
computations programmed into these procedures
are performed correctly. When bugs are found and
reported, I attempt to eliminate them as quickly as
possible. I offer this procedures to the research
community "as is" and accept no responsibility for
any negative consequences that might result from
their use.
If you have trouble getting anything on this
page to work or just have a question, first
check my "Rules and FAQ page" and read the
Home
My C.V.
Teaching and Speaking
Mechanisms and
Contingencies Lab
Introduction to
Mediation, Moderation,
and Conditional Process
Analysis
SPSS, SAS, and Mplus
Macros and Code
Mediation and
Moderation Analysis
Workshops
Communication Methods
and Measures
Video
Blog
Tweets
Introduction to Mediation, Moderation, and
Conditional Process Analysis.
3/12/2014 SPSS, SAS, and Mplus Macros and Code - Andrew F. Hayes, Ph.D.
http://www.afhayes.com/spss-sas-and-mplus-macros-and-code.html 2/8
documentation and corresponding journal articles before contacting me by email.
Download Instructions
On some computers, merely clicking on the file will successfully download the file. However, you
may find that the file opens up in a new browser window as text. In such cases, try right clicking
the file and selecting "save link as". If this procedure saves the file as an HTML file or an XML file on
your machine rather than an SPSS or SAS file, try adding the corresponding extension (e.g., .sps,
.sbd, .sbs, .sas) to the file name before saving. If all else fails, download the .zip file, if available. Do
not try cutting and pasting the text you might see on your browser after clicking the
link into an SPSS syntax or SAS program window. This will not work. You must
download the file.
Installing Custom Dialog files in SPSS
Here is a document on how to install custom dialog files into SPSS. If you can't solve a write or
installation permissions error, try this.
For macros (the .sps files or .sas files). Make sure you run the code exactly as downloaded in a
syntax or program file. Modifying the code will produce errors. Do not modify the code at all.
See the documentation for each of my macros for instructions on their use.
For real time updates about my work on mediation and moderation, "Like" my facebook page.
(Note: I do not answer questions posted on the wall of this page. Contact me at
hayes.338@osu.edu if you have questions not answered on my FAQ page)
PROCESS
PROCESS can be found on the web page for Hayes (2013).
. New York: Guilford Press. Twitter: #processmacro
INDIRECT
Preacher, K. J., & Hayes, A. F. (2008). Asymptotic and resampling strategies for
assessing and comparing indirect effects in multiple mediator models.
, 40, 879-891. [PDF].
This macro for SPSS and SAS estimates the path coefficients in a multiple mediator model and
generates bootstrap confidence intervals (percentile, bias-corrected, and bias-corrected and
accelerated) for total and specific indirect effects of on through a one or more mediator
variable(s) M. This is macro is far superior to SOBEL, as it allows for more than one mediator and
adjusts all paths for the potential influence of covariates not proposed to be mediators in the
model. Since the macro was originally published, many improvements have been made to the
SPSS version, including the ability to estimate models with dichotomous outcomes.
There have been some improvements to the SPSS version of INDIRECT since the 2008 paper was
published. Among the new features include the ability to estimate models with a
dichotomous outcome (Y) variable and the implementation of a faster algorithm for generating
bootstrap confidence intervals that greatly speeds up the generation of output.
Note: PROCESS is capable of doing everything that INDIRECT can do and a whole lot more. For a
discussion of the parallel multiple mediation model, see Chapter 5 of Hayes (2013).
Please read the download instructions at the top of this page.
SPSS Version
Documentation: indirect.pdf
Macro: indirect.sps
Custom Dialog: indirect.spd
Introduction to Mediation,
Moderation, and Conditional Process Analysis
Behavior
Research Methods
X Y
3/12/2014 SPSS, SAS, and Mplus Macros and Code - Andrew F. Hayes, Ph.D.
http://www.afhayes.com/spss-sas-and-mplus-macros-and-code.html 3/8
SAS Version
Documentation: indirect_sas.pdf
Macro: indirect.sas
Download all these files: indirect.zip
SOBEL
Preacher, K. J., & Hayes, A. F. (2004). SPSS and SAS procedures for estimating indirect
effects in simple mediation models.
, 717-731. [PDF]

This macro for SPSS and SAS estimates the size of an indirect effect of on through a single
mediator , and computes both normal theory (Sobels test) and bootstrap approaches for
inference. Although this is one of my more popular macros, INDIRECT (see above) can do
everything SOBEL can do, and a lot more. If you intend to use this macro merely to implement
the "Baron and Kenny" steps to mediation analysis or the Sobel test, I advise you against this, for
bootstrapping has become one of the more highly recommended approaches for inference about
indirect effects. For a rationale, read Preacher and Hayes (2004), or see Hayes, A. F. (2009).
Beyond Baron and Kenny: Statistical mediation analysis in the new millennium. Communication
Monographs, 76, 408-420 [PDF].
There have been many improvements made to the SPSS version of SOBEL since the 2004 paper
was published. Among these features include the ability to estimate models with a
dichotomous outcome (Y) variable, the generation of five measures of effect size, and the
implementation of a faster algorithm for generating bootstrap confidence intervals that greatly
speeds up the generation of output.
Note: PROCESS is capable of doing everything that SOBEL can do and a whole lot more. For a
discussion of statistical mediation analysis, see Chapters 4, 5, and 6 of Hayes (2013).
Please read the download instructions at the top of this page.
SPSS Version
Documentation: sobel.pdf
Macro: sobel.sps
Custom Dialog: sobel.spd
SAS Version
Documentation: see Preacher and Hayes (2004) for instructions
Macro: sobel.sas
Download all these files: sobel.zip
Here is an SPSS version of the data file used to produce Figure 2 in Preacher and Hayes (2004):
figure2.sav
MEDIATE
MEDIATE for SPSS is an alternative to PROCESS for conducting the kind of analysis described in
Hayes, A. F., & Preacher, K., J. (in press). Statistical mediation analysis with a
multicategorical independent variable. [email
me] DOI:10.1111/bmsp.12028
MEDIATE conducts mediation analysis (single and multiple mediators) with either continuous,
dichotomous, or multicategorical independent variables. It is similar in functionality to INDIRECT
but offers additional features that accommodate multiple independent variables simultaneously and
that simplify the coding of multicategorical independent variables. When analyzing the effect of a
Behavior Research Methods, Instruments, and
Computers, 36
X Y
M
British Journal of Mathematical and Psychology
3/12/2014 SPSS, SAS, and Mplus Macros and Code - Andrew F. Hayes, Ph.D.
http://www.afhayes.com/spss-sas-and-mplus-macros-and-code.html 4/8
multicategorical independent variable, the user can produce the requisite k - 1 variables coding
group (where k is the number of groups) manually and enter them as independent variables or
have MEDIATE automatically generate the variables using either indicator, effect, sequential coding,
or Helmert coding. It offers tests of relative direct and indirect effects, including percentile
bootstrap and Monte Carlo confidence intervals for indirect effects. It also automatically conducts
a test of homogeneity of regression (i.e., interaction between X and M in the model of Y).
Please read the download instructions at the top of this page.
SPSS version
Documentation: mediate.pdf
Macro: mediate.sps
There is no SPSS custom dialog version of MEDIATE, nor is there a SAS version. SAS users
interested in applying the method described in the this paper can use PROCESS as described in
Hayes, A. F., & Preacher, K., J. (in press). Statistical mediation analysis with a multicategorical
independent variable. DOI:10.1111/bmsp.12028
MODMED
Preacher, K. J., Rucker, D. D., & Hayes, A. F. (2007). Assessing moderated mediation
hypotheses: Theory, methods, and prescriptions. ,
185-227. [PDF]
This SPSS macro conducts tests of conditional indirect effects when assessing
, as described in Preacher, Rucker, and Hayes (2007). The syntax structure in this
version differs slightly from the structure described in Preacher, Rucker, and Hayes. See the
documentation for guidance.
Please read the download instructions at the top of this page.
SPSS Version
Documentation: modmed.pdf
Macro: modmed.sps
Corresponding Mplus code (version 5 or earlier)
Models 1 though 5: mplus1to5.pdf
NOTE: There is no custom dialog for MODMED, nor is there a SAS version. SAS users interested in the
functions of MODMED should use PROCESS instead. PROCESS is capable of doing almost all of what
MODMED can do, plus PROCESS can estimate a larger set of moderated mediation models, with multiple
mediators, as well as with dichotomous dependent variables. For a discussion of moderated mediation,
see Chapters 10, 11, and 12 of Hayes (2013).
MODPROBE
Hayes, A. F., & Matthes, J. (2009). Computational procedures for probing interactions
in OLS and logistic regression: SPSS and SAS implementations.
, 41, 924-936. [PDF].
This SPSS and SAS macro is used for probing single-degree-of-freedom interactions in linear and
logistic regression models. It implements the pick-a-point approach for estimating effects of a
focal predictor at specified values of the moderator as well as the Johnson-Neyman technique for
calculating regions of significance. It also generates estimated values of the outcome from the
model, which is useful for generating visual plots of the interaction. You might also check out a
paper of mine that describes the dangers of not knowing how to properly interpret the coefficients
in a regression model with interactions. And here is Chapter 16 from my book, Statistical Methods
for Communication Science, in which I discuss the estimation and interpretation of interactions in
linear models.
British Journal of Mathematical and Psychology
Multivariate Behavioral Research, 42
moderated
mediation
Behavior Research
Methods
3/12/2014 SPSS, SAS, and Mplus Macros and Code - Andrew F. Hayes, Ph.D.
http://www.afhayes.com/spss-sas-and-mplus-macros-and-code.html 5/8
Note: PROCESS is capable of doing everything that MODPROBE can do and a whole lot more. For
a discussion of moderation analysis, see Chapters 7, 8, and 9 of Hayes (2013).
Please read the download instructions at the top of this page.
SPSS Version
Documentation: modprobe.pdf
Macro: modprobe.sps
Custom Dialog: modprobe.spd
SAS Version
Documentation: modprobe_sas.pdf
Macro: modprobe.sas
Download all these files: modprobe.zip
For some instruction on how to plot an interaction in SPSS using the output from MODPROBE's
"est" option, click here.
Wilhelm Hofmann at the University of Chicago has produced some additional code that extends
some of the capabilities of MODPROBE. For details, go here.
Click here for a handy tool for plotting interactions in Microsoft Excel using output from
MODPROBE. This tool is provided by Melinda Morgan, adapted from an excel spreadsheet by
Jeremy Dawson.
Here is the logistic regression example mentioned in the Behavior Research Methods article.
If you are interested in probing a three way interaction, use PROCESS.
MEDCURVE
Hayes, A. F., & Preacher, K. J. (2010). Quantifying and testing indirect effects in simple
mediation models when the constituent paths are nonlinear. Multivariate Behavioral
Research, 45, 627-660. [PDF]
This macro estimates instantaneous indirect effects in simple mediation models with nonlinear
paths, as discussed in Hayes and Preacher (2010), and produces bootstrap confidence intervals
for inference. The X->M, M|X->Y, and X|M->Y paths can be estimated as linear, quadratic,
exponential, log, or inverse, in any combination, thereby allowing for the estimation of 125
different models. This macro can also do everything that SOBEL does by specifying all paths as
linear.
Please read the download instructions at the top of this page.
SPSS Version
Documentation: medcurve.pdf
Macro: medcurve.sps
Custom Dialog: medcurve.spd
SAS Version
Documentation: medcurve_sas.pdf
Macro: medcurve.sas
Note: There is an error in the equation for Y-hat at the bottom of page 640 of Preacher and Hayes (2010). This equation should read
Y-hat = -2.0823 + 1.1197(X) - 0.1292(X*X) + 0.7896(M). This does not affect any of the computations anywhere in the manuscript.
MEDTHREE and MED3C
3/12/2014 SPSS, SAS, and Mplus Macros and Code - Andrew F. Hayes, Ph.D.
http://www.afhayes.com/spss-sas-and-mplus-macros-and-code.html 6/8
Hayes, A. F., Preacher, K. J., & Myers, T. A. (2010). Mediation and the estimation of
indirect effects in political communication research. In E. P., & R. Lance Holbert (Eds),
Sourcebook for political communication research: Methods, measures, and analytical
techniques. New York: Routledge. [at the publisher's page]
These SPSS macros extend the SOBEL macro described in Preacher and Hayes (2004) to multiple
step models of the form 1 2 . Point and bootstrap 95% confidence intervals are
provided for indirect effects. Normal theory (a.k.a. Sobel) tests are not provided. MEDTHREE
assumes no covariates, whereas MED3C requires them.
Please read the download instructions at the top of this page.
SPSS Version
Documentation: medthree.pdf ; med3c.pdf
Macro: medthree.sps ; med3c.sps
Custom dialog: medthree.spd (medthree.spd can estimate models with controls, but does not
require them)
NOTE: PROCESS is capable of doing everything MEDTHREE and MED3C can do and
provides much more detail. In addition, PROCESS allows up to four mediators to be
chained together in a causal sequence. For a discussion of the serial mediation model,
see Chapter 5 of Hayes (2013).
HCREG
Hayes, A. F., & Cai, L. (2007). Using heteroscedasticity-consistent standard error
estimators in OLS regression: An introduction and software implementation.
, 709-722.
[PDF]
This macro for SPSS and SAS is used for estimating OLS regression models but with
heteroscedasticity-consistent standard errors using the HC0, HC1, HC2, HC3, and HC4 procedures
described by MacKinnon and White (1985), Long and Ervin (2000), and Cribari-Neto (2004).
Please read the download instructions at the top of this page.
SPSS Version
Documentation: see the Appendix of the article
Macro: hcreg.sps
Custom Dialog: hcreg.spd
SAS Version
Documentation: see the Appendix of the article
Macro: hcreg.sas
NOTE: PROCESS for SPSS and SAS implements the HC3 standard error estimator for models
involving mediation and/or moderation components.
NOTE: A bug was found in August of 2011 in hcreg.spd that affected some of the standard error
computations. If you downloaded and installed the SPSS custom dialog version of HCREG before
27 August 2011, I recommend you download the latest version and reinstall. This bug did not
affect any computations in hcreg.sas or hcreg.sps.
KALPHA
Hayes, A. F., & Krippendorff, K. (2007). Answering the call for a standard reliability
measure for coding data. Communication Methods and Measures, 1, 77-89. [PDF]
This macro computes Krippendorff's alpha reliability estimate for subjective judgments made at any
X M M Y
Behavior
Research Methods, 39
3/12/2014 SPSS, SAS, and Mplus Macros and Code - Andrew F. Hayes, Ph.D.
http://www.afhayes.com/spss-sas-and-mplus-macros-and-code.html 7/8
level of measurement, any number of judges, with or without missing data.
Please read the download instructions at the top of this page.
SPSS Version
Documentation: kalpha.pdf
Macro: kalpha.sps
Custom Dialog: kalpha.spd (installs into the "Descriptives" menu under "Analyze")
SAS Version
Documentation: see the comments at the top of the code
Macro: kalpha.sas
Here is a document that describes the bootstrapping algorithm.
Download all these files: kalpha.zip
HETREG
Cai, L., & Hayes, A. F. (2007). A new test of linear hypotheses under heteroscedasticity
of unknown form. Journal of Educational and Behavioral Statistics, 33, 21-40. [PDF]
This SAS macro implements a new test for the regression coefficients in OLS regression that does
not assume homoscedasticity. The paper includes some simulation results showing its superiority
over the heteroscedasticity-consistent standard error estimators summarized by Long & Ervin
(2000).
Please read the download instructions at the top of this page.
SAS Version
Documentation: See Appendix B of the article.
Macro: hetreg.sas
ALPHAMAX
This paper describes an SPSS and SAS macro that generates all possible subscales of at least two
items from an additive scale containing items. For each possible subscale, it generates
Cronbachs alpha and the subscale-full scale correlation and displays information about each
subscale in a data spread sheet. It also generates summary statistics making it easy to find the
most psychometrically appealing subscale in the set as well as some item analysis statistics useful
for scale construction. To download the SPSS macro, click here. For the SAS version, click here.
See the paper for instructions on the use of the macro.
MCMED
This macro, available for SPSS and SAS, constructs a Monte Carlo confidence interval for the
indirect effect in statistical mediation analysis. Its use is described in Chapter 4 and Appendix B of
Introduction to Mediation, Moderation, and Conditional Process Analysis. You can obtain MCMED
by downloading the PROCESS zip archive on the web page for this book.
HOTDECK
Myers, T. A. (2011). Goodbye listwise deletion: Presenting hotdeck imputation as an
easy and effective tool for handling missing data. Communication Methods and Measures, 5,
297-310. [PDF]
I am hosting and provide a link to this paper and the corresponding macro as a courtesy to Teresa
Myers and the journal I edit, Communication Methods and Measures. This SPSS macro implements
k
3/12/2014 SPSS, SAS, and Mplus Macros and Code - Andrew F. Hayes, Ph.D.
http://www.afhayes.com/spss-sas-and-mplus-macros-and-code.html 8/8
hot deck imputation of missing data. I have found this macro very useful in my own research,
and if you work with large data sets, I think you will as well. To download the macro, click here,
following the download instructions described at the top of this page. If you have any questions,
direct them to Teresa Myers. Instructions for using this macro can be found in the corresponding
paper.

You might also like