Example - Recording an Analysis Macro

When running analyses in STATISTICA, all options and output choices are automatically recorded; when you create an Analysis Macro (via Options - Create Macro), the complete recording of all your actions are translated into a STATISTICA Visual Basic program that can be run to recreate the specific analysis. Thus, programming in STATISTICA can be extremely simple.

Analysis Macros will record the settings, selections, and chosen options for a specific analysis. Note that the term "analysis" in STATISTICA denotes one task selected either from the Statistics or Graphs tab or menu, which can be very small and simple (e.g., one scatterplot requested from the Graphs tab or menu), or very elaborate (e.g., a complex structural equation modeling analysis selected by choosing that option from the Statistics tab or menu and involving hundreds of output documents. STATISTICA also provides facilities to record Keyboard Macros as well as Master Macros (logs). Master Macros will contain logs of your entire analysis; this recording will "connect" analyses performed with various analysis options from the Statistics or Graphs menus. However, unlike simple Analysis Macros, you can turn the recording of Master Macros on or off. The Master Macro recording will begin when you turn on the recording, and it will end when you stop the recording. In between these actions, all file selections and most data management operations are recorded, as are the analyses and selections for the analyses, in the sequence in which they were chosen.  

This example illustrates how to create an Analysis Macro from a simple analysis:

Start STATISTICA, open the example data file Exp.sta, and start Basic Statistics/Tables. In the Basic Statistics and Tables Startup Panel, select Descriptive statistics and click the OK button. In the Descriptive Statistics dialog box, click the Variables button and select all variables for the analysis. Then click the Summary: Statistics button to display the descriptive statistics summary spreadsheet. When the spreadsheet is displayed, the Descriptive Statistics dialog box is minimized on the Analysis bar. Click the Descriptive Statistics button on the Analysis bar to maximize the dialog box. Next select the Normality tab, and click the Histograms button; histograms for all variables will be computed.

The STATISTICA Visual Basic code that will reproduce this analysis, which has been "accumulated" by the program, can be displayed in the STATISTICA Visual Basic Editor in one of two ways. If the current analysis dialog is minimized, right-click on the button representing the current analysis on the Analysis bar, and select Create Macro from the resulting shortcut menu.

Alternatively, with the analysis dialog maximized, click the Options button and select Create Macro from the resulting menu.

After you select this option, the New Macro dialog box is displayed. Call the new macro MyMacro. Click the OK button, and the new macro will be displayed in a stand-alone window. Stand-alone macro programs have to be loaded before they can run, while global macro programs (created by selecting Save As Global Macro from the File menu) become part of STATISTICA; that is, they will automatically be loaded the next time you run STATISTICA.

By default, global macros will be available in the Macro Manager (accessed by selecting Macros from the Tools - Macro menu). Global macros are the same as standard macros or SVB programs except that they are located in the same directory (by default) where the STATISTICA startup program file is located. When you select Save as Global Macro from the File menu, this directory will automatically be preselected. Save your frequently used macros via Save as Global Macro so that they are readily available when you start up STATISTICA the next time. Of course, you can always later and "by hand" (e.g., via the Windows operating system functions) move macros in and out of the startup (global macro) directory.

To run this macro, press F5 or click the Run Macro button on the Macro toolbar.