My workshop schedule on mediation and moderation analysis using PROCESS can be found on the PROCESS page.

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

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 the general guidance I offer at the bottom of this web page, and read the documentation and corresponding journal articles before contacting me by email.

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 the general guidance I offer at the bottom of this web page, and read the documentation and corresponding journal articles before contacting me by email.

MEMORE

(

MEMORE is a macro for SPSS and SAS that estimates the total, direct, and indirect effects of

Moderation functions have not yet been implemented in MEMORE.

Here is a direct link to the MEMORE files.

If you have questions about the use of MEMORE, email Amanda Montoya (montoya.29@osu.edu)

(

__ME__diation and__MO__deration in__RE__peated-measures designs)**Montoya, A. K., & Hayes, A. F. (in press). Two condition within-participant statistical mediation analysis: A path-analytic framework.***Psychological Methods*. [PDF][email for a copy]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.

**Download MEMORE from Amanda Montoya's web page.**Here is a direct link to the MEMORE files.

If you have questions about the use of MEMORE, email Amanda Montoya (montoya.29@osu.edu)

**RLM****Darlington, R. B. & Hayes, A. F. (2017).**

*Regression analysis and linear models: Concepts, application, and implementation*. New York: The Guilford Press [purchase]The RLM macro was released with the publication of

*Regression Analysis and Linear Models*in the summer of 2016. It can be downloaded from the book's web page and is documented in Appendix A of the book. Available for SPSS and SAS, RLM is a supplement to SAS and SPSS's regression modules. In addition to the usual regression program output, it has options for heteroscedasticity-consistent inference (using either the HC0, HC1, HC2, HC3, or HC4 variance-covariance matrix), automatic coding of a multicategorical categorical regressor, options for estimating and probing interactions involving a multicategorical regressor, all subsets regression, spline regression, crossvalidation indices for the multiple correlation, an implementation of a limited form of dominance analysis, contrasts between regression coefficients, and a few other features.

**OGRS****Hayes, A. F., & Montoya, A. K. (2016). A tutorial on estimating, visualizing and probing an interaction involving a multicategorical independent variable in linear regression analysis.**

*Invited manuscript submitted for publication*[PDF]

OGRS (Omnibus Groups Regions of Significance) is a macro for SPSS and SAS that implements the Johnson-Neyman technique (via iterative approximation) for probing an interaction when the independent variable is multicategorical (i.e., three or more groups) and the moderator is continuous. It was written by Amanda Montoya and is described, tested, and documented in Montoya (2016). The paper referenced above illustrates its use.

**Download OGRS from Amanda Montoya's web page.**

Here is a direct link to the OGRS files.

If you have questions about the use of OGRS, email Amanda Montoya (montoya.29@osu.edu)

__INDIRECT__

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

To learn more about mediation analysis, take a course from Andrew F. Hayes in July of 2016. Here are the details.

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: INDIRECT is

**obsolete**with the release of PROCESS. 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). To learn more about PROCESS and download, go here.

Download INDIRECT: indirect.zip

**INDIRECT is obsolete with the release of PROCESS. To learn more about PROCESS, see Hayes (2013). PROCESS can be downloaded from processmacro.org.**

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

**With the release of PROCESS v2.15 in January 2016, MEDIATE is obsolete. If you want to use the method described in Hayes and Preacher (2014), you can now use PROCESS. PROCESS can also handle more than one independent variable in mediation models using the trick described in Chapter 6 of Hayes (2013).**

To learn about mediation analysis with a multicategorical independent variable, take a course in July 2016 with Andrew F. Hayes. Here are the details.

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

Download MEDIATE: mediate.zip

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 for SAS.

__SOBEL__

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 was once a very popular macro, PROCESS (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), Hayes, A. F. (2009). Beyond Baron and Kenny: Statistical mediation analysis in the new millennium. Communication Monographs, 76, 408-420 [PDF], or see section 6.1 of Hayes (2013).

**SOBEL is obsolete with the release of PROCESS. To learn more about PROCESS, see Hayes (2013). PROCESS can be downloaded from processmacro.org.**

**SOBEL is now available only by special request by email.**

__MODMED__

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.

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

**MODMED is obsolete with the release of PROCESS. To learn more about PROCESS, see Hayes (2013). PROCESS can be downloaded from processmacro.org. Email me if you would still like to use MODMED, and I will tell you how to download it. You will find PROCESS much more useful than MODMED.**

__MODPROBE__

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.

**MODPROBE is obsolete with the release of PROCESS. To learn more about PROCESS, see Hayes (2013). PROCESS can be downloaded from processmacro.org.**

Note: PROCESS and RLM are 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) or Chapters 13 and 14 of Darlington and Hayes (2016).

Download MODPROBE: modprobe.zip

For some instruction on how to plot an interaction in SPSS using the output from MODPROBE's "est" option, click here.

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 for SPSS and SAS 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.

Download MEDCURVE: medcurve.zip

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

__HCREG__

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

**NOTE:**This macro is obsolete with the release of RLM, which is available for both SPSS and SAS and implements the HC0, HC1, HC2, HC3, and HC4 standard error estimators discussed in this article. RLM is documented in Darlington and Hayes (2017). Unlike HCREG, RLM can also estimate and probe interactions involving a multicategorical variable.

Download HCREG: hcreg.zip

Documentation: see the Appendix of the article

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

Download KALPHA: kalpha.zip

Here is a document that describes the bootstrapping algorithm.

__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

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

**Some General Guidance on the Use of Macros**

(1) Read the article corresponding to the macro before you attempt to use it. I also recommend you download and also

**read**the documentation for the macro, as it may answer many questions you might have. I get many questions about my macros, a substantial number of them which are answered in the documentation. As a general rule, I don't answer questions sent to me by email that are answered in the documentation.

(2) Download and run the macro definition command set (the .sps file or .sas file) EXACTLY AS IS from the web page.

**Do not modify the code at all.**Many users mistakenly change the program by customizing it to their own data or variables. This will produce an error. DO NOT MODIFY THE MACRO IN ANY WAY. JUST RUN IT EXACTLY AS IS. IT WILL EITHER DO NOTHING, OR SPSS or SAS WILL PRINT BACK THE COMMANDS IN THE OUTPUT OR LOG WINDOW. This is good. After you have done this, you then execute a properly formatted command as described in the documentation for the macro you are using.

(3) All macros produce an SPSS or SAS command defined by the macro name. It is through this command that you get the macro to work. The syntax structure for the macro can be found in the documentation or, in some cases, in the published article that describes the macro’s functionality. For lessons on how to run SPSS commands through the syntax system, consult the SPSS help files or an SPSS manual.

(4) You do not need to run the macro command definition set more than once. Although there is no harm in doing so, the second time you do, you may get a WARNING message from SPSS saying something like

>Warning # 6804 in column 3.

>The macro name specified on the DEFINE command duplicates the

>name of a previously defined macro. This instance will take precedence.

This is a harmless warning and need not concern you. Many users believe they have done something wrong when this warning appears.

(5) If you do not properly execute the macro command definition set and then attempt to use the macro, you will get an error (in SPSS) that reads something like

>Error # 1. Command name: process

>The first word in the line is not recognized as an SPSS Statistics command.

>Execution of this command stops.

It may be that you

*think*you executed the macro, but SPSS doesn't believe you have, and SPSS is usually right. One possible cause of this error is that you executed the macro in one copy of SPSS but you have another copy of SPSS running simultaneously where you did not execute the macro, and you are trying to run your command in the version in which you did not execute the macro. Another possibility is that you didn't run the entire program but only part of it.

(6) Make sure you run the ENTIRE macro command set on the web page. Many users mistakenly leave off the last line and then try to rerun the command set when nothing happens. In SPSS, this will might produce an error that looks something like

>Error # 6805 in column 1. Text: DEFINE

>There is an instance of a DEFINE command nested within another DEFINE.

Nested DEFINE's are not permitted.

Typically there is no way out of this. You’ll have to quit SPSS and start again. Or you may get the error in (5) when you try to use the macro.

(7) If nothing happens when you run the macro command set on the web page, THAT IS OK. The macro will do nothing until you then execute the macro command by feeding it the parameters pertinent to your analysis and data set. The web page describes the acceptable syntax to make the macro do what it can do. Many errors become infinite loops and are nearly impossible to escape. Quitting SPSS or SAS and starting fresh is usually the only option available in such cases.

(8) My macros were written on SPSS for Windows but they work on the Mac as well. If you are using a version of SPSS prior to release 17, you may get nothing but errors. I recommend you upgrade to a more recent version of SPSS.

(9) These macros don’t work with the INCLUDE command. If you are getting errors and are using the INCLUDE command to execute the macro definition commands from a file, try running the macro definition program manually, without the INCLUDE command. Or Try the INSERT command instead.

(10) I no longer support scripts and have removed them from my web page. The custom dialog files (with an .spd extension) install permanently in SPSS and provide a dialog box for setting up the procedure for your analysis.

**You must have administrative access to your machine in order to install a custom dialog file.**If you are getting an installation error when attempting to install an *.spd file, this is because you aren't authorized to install on your machine. An example installation error might look something like:

“Cannot install custom dialog to any of the specified locations: C:\PROGRA~1\IBM\SPSS\STATIS~1\20\ext\lib“.

although the error could take a number of different forms.