|Tutorial sections and descriptions:
What Is an SPSS Macro?
An SPSS macro functions as a “mini program” within the syntax of SPSS. These mini programs are written in a combination of a special SPSS macro language and the familiar SPSS syntax language. Similar to other programs, macros serve to “automate” a series of operations which would be much more time-consuming or complex to perform by issuing commands one step at a time. The SPSS macro language is quite flexible. Macros can conduct a whole series of analyses, make adjustments to multiple output statistics, produce multiple charts with many combinations of variables, or any number of other tasks.
After a macro has been defined, written, and saved, it can be used by “Calling” it.
When Might I Use an SPSS Macro?
Suppose you run weekly analyses for a marketing company. Your report provides descriptive statistics and regression models to examine the impacts of several marketing campaigns on company profits. Assuming you need to run similar analyses for 12 sets of variables every week, these analyses could be performed using one of three methods. These methods and estimates of time required are as follows:
This example involves only one simple application of SPSS macros, used for a relatively straightforward task, performed once-per-week. While the time-saving potential of a well-designed macro is apparent here, it becomes even more attractive for more complex or frequent SPSS tasks (imagine the previous example, performed every day, using 100 sets of variables, and requiring subtle adjustments to multiple output statistics).
There are many applications for using macros. For instance, macros can be used to conduct tests of mediation and moderation in regression, estimate path coefficients of other indirect effects, or to perform bootstrapping functions. SPSS macros are fairly easy to create if you have a fundamental understanding of SPSS syntax. There are literally thousands of ready-made macros freely available online. Raynald’s SPSS Tools site has a large collection.
Using SPSS Macros
In order to use an SPSS macro, the macro must be
Step 1: Saving SPSS Macros
Step 2: Including an SPSS Macro in a Session
For example, if a macro called “!screen” was saved on the “C drive”; in the “My Documents” folder, you could include it by using the following command in SPSS syntax:
If the macro has been saved in the same directory as other SPSS files in the open project, it can be included without including the file directory, as in:
Step 3: Calling an SPSS Macro
Example of an SPSS macro
Here is SPSS syntax that includes definition of a macro and calling the macro. This simple macro provides screening information on variables, including skew and kurtosis and the maximum and minimum values, along with a histogram showing the shape of each distribution.
You can find more information on SPSS macros at Macro Tutorial by Raynald Levesque.
More technical information from SPSS on macros and other syntax applications is available here
Matthew Galen and Dale Berger, updated 21 April 2015
3,864 total views, 5 views today