Using Macros to Publish Statistical Reports

Bruno Scibilia 08 November, 2011

Macros are very useful for automating and processing sequences of repetitive tasks. For example, generating periodic reports (weekly, monthly or quarterly) often becomes a very tedious and time-consuming activity. The graphs and statistical analyses contained in these reports need to be updated regularly and are always the same (although the data change).

Fortunately, these repetitive tasks can easily be automated with the help of some very simple macros.

You do not need to become a macro expert to automate long sequences of tasks. I'm going to present an example of how graphs and statistical analyses from Minitab Statistical Software may be (easily) published into a report.

As you conduct statistical analyses and create graphs, Minitab software keeps track of the commands followed and stores them in a History window. Look for this yellow icon in the Minitab toolbars to find the History folder:
 
Minitab History Icon
 
This History facility considerably helps the creation of macros. To create a macro, you just need to retrieve the corresponding command lines from the History window: select the session commands, then, with a right click, save the selected commands as .MAC (macro) or .MTB (executable file).  It is not necessary to understand the meaning of each session command to create a macro.

Suppose that we have a report to do that requires several steps. First, we need to retrieve data from an Excel file. Next we need to run a capability analysis on 10 variables. We also would like to obtain some SPC control charts and a boxplot from the same data. Finally, we would like to create a PowerPoint or a Word file that contains all our analyses and graphs, so that such a report could be presented to the company management. And, of course, this rather long sequence of tasks needs to be rerun at the end of every month.

You can see below what the sequence of commands looks like in the History window. This is what you would select and save as a .MAC or .MTB file:

macro

Then, to finalize the macro, we open the .MAC or .MTB file with Wordpad/Notepad and add the following command at the end of the sequence:

XPPOINT

to create a Powerpoint document with all the graphs and analyses, or

XWORD

to create a Word document.  If we use the PowerPoint command, running the macro yields the following document: 

powerpoint

The macro can then be run periodically in a number of different ways:

  • For an executable file (.MTB) select the following function in Minitab: File>Other Files>Run an Exec
  • For a .MAC file select: Edit>Command Line Editor> then type ‘%name of the macro.mac’ (for example, %Caparepeat.mac)

It is also possible to create an icon in the Minitab software toolbar that is associated with this macro. When you click on this icon, the macro will run automatically. With a single click you could get your full statistical report each month!

Macro icon

You can learn more by checking out the "Using Macros" section of Minitab Help.  You can also visit the Minitab Macros Library on our site to see and download macros created by Minitab specialists as well as members of the Minitab user community.