**Just a few seats remain for Andrew's course,**

*Introduction to Mediation and Moderation Analysis*, in Philadelphia, July 13-17, 2015. [details]**[download flyer].**

## 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 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.

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)

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 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)

**MEDIATE**MEDIATE for SPSS is an alternative to PROCESS for conducting the kind of analysis described in

**Hayes, A. F., & Preacher, K., J. (2014). Statistical mediation analysis with a multicategorical independent variable,**

*67*, 451-470.

*British Journal of Mathematical and Statistical Psychology*[email me for a copy] DOI:10.1111/bmsp.12028 [online supplement]

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 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 (.spd) 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. (2014). Statistical mediation analysis with a multicategorical independent variable.

*British Journal of Mathematical and Statistical Psychology, 67,*451-470. [online supplement] DOI:10.1111/bmsp.12028

**COMING SOON!**

MEMORE

**(**

__ME__diation and__MO__deration in__RE__peated-measures designs)MEMORE is a macro for SPSS and SAS that estimates the total, direct, and indirect effects of

*X*on

*Y*through one or more mediators

*M*in the two-condition or two-occasion within-subjects/repeated measures design. In a path-analytic form using OLS regression as illustrated in Montoya and Hayes (2015), it implements the method described by Judd, Kenny, and McClelland (2001,

*Psychological Methods*) and extended by Montoya and Hayes (2015) to multiple mediators. Along with an estimate of the indirect effect(s), MEMORE generates confidence intervals for inference about the indirect effect(s) using bootstrapping, Monte Carlo, or normal theory approaches. MEMORE also provides an option that conducts pairwise contrasts between specific indirect effects in models with multiple mediators.

Moderation functions have not yet been implemented in MEMORE.

If you would like to be a beta-tester of MEMORE, send an email to Amanda Montoya (montoya.29@osu.edu) to obtain access to the MEMORE files.

INDIRECT

Preacher, K. J., & Hayes, A. F. (2008). Asymptotic and resampling strategies for assessing and comparing indirect effects in multiple mediator models.

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

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

SAS Version

Documentation: indirect_sas.pdf

Macro: indirect.sas

Download all these files: indirect.zip

Preacher, K. J., & Hayes, A. F. (2008). Asymptotic and resampling strategies for assessing and comparing indirect effects in multiple mediator models.

*Behavior Research Methods*, 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

*X*on*Y*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.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

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.

This macro for SPSS and SAS estimates the size of an indirect effect of

Preacher, K. J., & Hayes, A. F. (2004). SPSS and SAS procedures for estimating indirect effects in simple mediation models.

*Behavior Research Methods, Instruments, and Computers, 36*, 717-731. [PDF]This macro for SPSS and SAS estimates the size of an indirect effect of

*X*on*Y*through a single mediator*M*, and computes both normal theory (Sobel’s 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 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]. Also see section 6.1 of Hayes (2013).

SOBEL is now available only by special request by email. SOBEL is obsolete with the release of PROCESS. To learn more about PROCESS, see Hayes (2013). PROCESS can be downloaded from processmacro.orgSOBEL is now available only by special request by email. SOBEL is obsolete with the release of PROCESS. To learn more about PROCESS, see Hayes (2013). PROCESS can be downloaded from processmacro.org

MODMED

Preacher, K. J., Rucker, D. D., & Hayes, A. F. (2007). Assessing moderated mediation hypotheses: Theory, methods, and prescriptions.

This SPSS macro conducts tests of conditional indirect effects when assessing

Please read the download instructions at the top of this page.

SPSS Version

Documentation: modmed.pdf

Macro: modmed.sps

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).

Preacher, K. J., Rucker, D. D., & Hayes, A. F. (2007). Assessing moderated mediation hypotheses: Theory, methods, and prescriptions.

*Multivariate Behavioral Research, 42*, 185-227. [PDF]This SPSS macro conducts tests of conditional indirect effects when assessing

*moderated mediation*, 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

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

MODPROBE was originally released in 2009 and is described in

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.

In May 2015, MODPROBE 2.0 was released. This new release includes a feature for estimating models with a multicategorical (three or more levels) focal predictor or moderator. It also adds an option for heteroscedasticity-consistent inference.

Note: PROCESS is capable of doing may things 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.

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 estimating and probing a three way interaction, use PROCESS.

MODPROBE was originally released in 2009 and is described in

**Hayes, A. F., & Matthes, J. (2009). Computational procedures for probing interactions in OLS and logistic regression: SPSS and SAS implementations.***Behavior Research Methods*, 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.

In May 2015, MODPROBE 2.0 was released. This new release includes a feature for estimating models with a multicategorical (three or more levels) focal predictor or moderator. It also adds an option for heteroscedasticity-consistent inference.

Note: PROCESS is capable of doing may things 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.

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 estimating and 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.

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

Hayes, A. F., Preacher, K. J., & Myers, T. A. (2010). Mediation and the estimation of indirect effects in political communication research. In E. P. Bucy & R. Lance Holbert (Eds), Sourcebook for political communication research: Methods, measures, and analytical techniques. New York: Routledge. [at the publisher's page]

MEDTHREE and MED3C have been discontinued. PROCESS is capable of doing everything these can do and PROCESS provides much more detailed output and many more options. MEDTHREE and MED3C are thus obsolete. For a discussion of the serial mediation model described in this book chapter, see Chapter 5 of Hayes (2013).

Hayes, A. F., Preacher, K. J., & Myers, T. A. (2010). Mediation and the estimation of indirect effects in political communication research. In E. P. Bucy & R. Lance Holbert (Eds), Sourcebook for political communication research: Methods, measures, and analytical techniques. New York: Routledge. [at the publisher's page]

MEDTHREE and MED3C have been discontinued. PROCESS is capable of doing everything these can do and PROCESS provides much more detailed output and many more options. MEDTHREE and MED3C are thus obsolete. For a discussion of the serial mediation model described in this book chapter, 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.

[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

Hayes, A. F., & Cai, L. (2007). Using heteroscedasticity-consistent standard error estimators in OLS regression: An introduction and software implementation.

*Behavior Research Methods, 39*, 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.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 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

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 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

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

This paper describes an SPSS and SAS macro that generates all possible subscales of at least two items from an additive scale containing

*k*items. For each possible subscale, it generates Cronbach’s 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.