Automating Metrics: creating your first macro

LinkedIn

We have talked about the format, now how do get the commands?

Two ways of getting the commands to put into a macro,

1. Copy and paste from the history menu. It can be found with an icon on the tool bar that is yellow with a > in it.

2. From any completed chart/graphic. With the chart open, you go to the editor menu a the top “Editor>Copy Command Language”. This function is not available with a right click.

The graphical summary is one graphic that can only be generated with the menu commands, the copy command language will not work.

Another nice thing to know is that any line in the macro file that has a first character as a (#) will be interpreted as a comment. You can use this to write notes to yourself and identify where different actions are taken in the macro.

Now for an example:

We will create a random normal data set with 25 numbers, make a histogram and an I chart.

If you try it yourself, start with a blank minitab project (just opened minitab) in order to duplicate my information

Make normal data
Calc>Random Data>Normal
25 rows, with a column name of data.
Leave a mean of 0 and standard deviation of 1

Graph>Histogram Simple
data variable is data

Stat>control charts>variables charts for individuals>individual…
varriable is Data

Look into the History Window and you should see the following

Name c1 “data”
Random 25 ‘data’;
Normal 0.0 1.0.
Histogram ‘data’;
YFrequency;
Bar.
IChart ‘data’.

Now lets create a macro and run it.

Open Notepad (or other text editor)
On the first two lines type;
gmacro
testmacro.

Now copy and paste the 7 lines from the history window in minitab (shown above)

now type
endmacro.
on a new line at the end, (note there is a period after endmacro and testmacro.)

Now perform a “save as” and save the text file to the Minitab Macro Directory. Use the name of
myfirstmacro.mac
Now you have to change the file type from .txt to all or it will append the .txt on the end of your file.

For V15 the default macro directory is found at;
C:\Program Files\Minitab 15\English\Macros\

To run the macro. Open a new minitab project that is blank.
Edit>Command Line Editor (or CTRL-L)

type in
%myfirstmacro
and then press the submit commands button and it will run.

More About Rick Haynes


I am a Statistician and Master Black Belt who has worked in Manufacturing, R&D, and Non-Manufacturing businesses performing process improvements and statistical support for Scientists and Engineers since 1986. My original Six Sigma Training was with Motorola in the 80s and I have been a instructor of Six Sigma and Statistics since the mid 90's.

LinkedIn

One Response to “Automating Metrics: creating your first macro”

  1. Using Macros to automate Minitab to produce scorecards and metrics. | Practitioner's Toolbox Says:

    […] Automating Metrics: Minitab Macros I have been working with a few students about using Minitab to generate performance metrics for use in their business. If you do this by hand it is very time consuming. I will talk about a few topic… Apr 09, 2009 Automating Metrics: creating your first macro […]

Leave a Comment

Name (required)

Email (will not be published)

Website (optional)

Categories


Archives

  • May 2016
  • February 2016
  • January 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • April 2015
  • March 2015
  • February 2015
  • January 2015

Links