dcsimg
 

Using Macros to Publish Statistical Reports

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.

7 Deadly Statistical Sins Even the Experts Make

Do you know how to avoid them?

Get the facts >

Comments

Name: John Inman • Thursday, May 10, 2012

Is there any way to print just the graphs? Not the entire session.


Name: Bruno Scibilia • Friday, May 11, 2012

Hello,

You can append all graphs created to the ReportPad in Minitab using the code below (in your macro):

gman;
append;
all.

If you only want to append one graph at a time, to the Minitab Reportpad, the following code will append the last graph created:

gman;
append.

Thank you.


Name: Karelly Villa • Tuesday, August 28, 2012

Is there a command to keep the order when the graphs and data go into the microsoft work document? Or a way I can append descriptive stats into the minitab report?


Name: Bruno Scibilia • Tuesday, August 28, 2012

When using the XPPOINT or XWORD commands in a Minitab macro the graphs and analyses that have been selected will be transfered into Power Point or into Word in the same order as they have been created in your macro (or in Minitab). You therefore need to be careful about the order in which graphs and analyses are created in Minitab before using the XWORD, XPPOINT commands.
In order to append descriptive Stats, just select manually the section that needs to be appended, right click and select Append to report (no macro command available for that, unfortunately).


Name: Kien Vu Tat • Wednesday, September 18, 2013

How to save or export graph as image file by using command line, don't using Macros?

Thank you!


Name: Bruno Scibilia • Wednesday, September 18, 2013

In the Project Manager section list, just right-click any graph, you've created in Minitab, and choose Save Graph as, or alternatively, click directly on the graph and go to > File > Save selected graph as.
Minitab graphs can be saved as an image in an MGF format (Minitab Graph), a JPEG or a TIF or a BMP etc...format.
You can also use the GSAVE "filename" session command.
Thank you.


blog comments powered by Disqus