Common Elements of Recorded Macro (SVB) Programs
The macro (SVB) programs recorded by Statistica use several common elements in addition to the properties and methods that are specific to the particular analysis objects. For example, almost all analyses require you to specify one or more variable lists, and in some cases sets of codes to identify groups in the input data. Also, each analysis has specific options relevant to the particular analysis, such as the specifications for censoring in Survival Analysis, which is not relevant to analyses available in Basic Statistics.
Set newanalysis = Analysis (scBasicStatistics)
In this statement, variable newanalysis is (implicitly) declared as an Analysis object. The constant scBasicStatistics causes an analysis of type Basic Statistics to be created. Refer to Statistica Libraries and Modules for a complete listing of analysis constants, and the types of analyses that they create.
The With ... End With block; specifying dialogs. If you have looked at a few recorded macro (SVB) programs, you will have noticed that practically all of them include With ... End With blocks. This is a shortcut method for setting the options (properties) in a particular dialog. In general, the specification:
With newanalysis.Dialog
.Variables = "5 6 7 8" .ConfidenceIntervalForMeansPlot = 95 .CompressedStemAndLeaf = False
End With
is equivalent to specifying these three options like this:
newanalysis.Dialog.Variables = "5 6 7 8" newanalysis.Dialog.ConfidenceIntervalForMeansPlot = 95 newanalysis.Dialog.CompressedStemAndLeaf = False
The With .. End With block is recorded 1) when you move forward to the next dialog or back to the previous dialog (via .Run or .GoBack; see also below), 2) when you explicitly request that the macro be written out to the SVB program editor, or 3) whenever you select an output method, i.e., create results spreadsheets or graphs. In the latter case, to make the recorded macro (SVB) programs more compact, the program will automatically analyze which properties have changed from one results spreadsheet (or graph) to the next, and only record those properties that have changed (if any).
With newanalysis.Dialog
.Variables = "5 6 7 8 | 1 2 3 4"
'...
With newanalysis.Dialog
.Variables = "5 6 7 8 | 1 2" .Codes = "EXPERMTL-CONTROL | MALE-FEMALE"
End With
The .Codes property is usually set by assigning to it a string. In this specific example, the codes are identified by 8-character short text labels. They can also be specified as code numbers (i.e., as the actual integer codes that were used in the data file to identify groups):
.Codes = "1 2 | 1 2"
When the text labels contain special embedded characters such as spaces, you will see double-quotation marks to distinguish between the different labels:
.Codes = """Experimental group""-""Control group"" | ""MaleParticipants""-""Female participants"""
Finally, the .Codes properties can also simply be omitted. Remember that the automation model for the Statistica modules follows the flow of dialogs in the interactive analysis, and when you run, for example, the Breakdown analyses interactively, you will notice that you do not have to specify the code values explicitly. By default, the program will determine the (integer) codes found in the respective variables in the data file. Hence, if you omit the .Codes property from the automation, then the program will do the same thing, i.e., determine the codes from the values found in the input data file.
These fields would be recorded in the With ... End With block representing this dialog in the following manner:
With newanalysis.Dialog
.Variables = "5 6 7 8 | 2" .CodeForGroup1 = "MALE" .CodeForGroup2 = "FEMALE" '...
End With
Note that, as is the case when specifying lists of codes, the properties .CodeForGroup1 and .CodeForGroup2 can also be set by assigning individual values (e.g., .CodeForGroup1=1). When the text labels for a variable contain embedded spaces or other special characters, the text labels assigned to the respective property will be enclosed in double quotation marks; for example:
.CodeForGroup1 = """MaleParticipants""" .CodeForGroup2 = """Female participants"""
With newanalysis.Dialog
.Variables = "5 6 7 8 | 2" .CodeForGroup1 = "MALE" .CodeForGroup2 = "FEMALE" .PairwiseDeletionOfMD = True .DisplayLongVariableNames = True .TTestWithSeparateVarianceEstimates = False .MultivariateTest = False .Levene = False .BrownForsythe = False .PLevelForHighlighting = 0.05
End With
Check boxes and option buttons are checked or cleared by assigning True or False to the corresponding property. Instead of True or False, these properties can be set by assigning 1 or 0, respectively. Numeric input fields are set by assigning the respective values (e.g., PlevelForHighlighting = 0.05). As with all properties in SVB, properties corresponding to dialog check boxes or option buttons can also be set by assignment of a variable of type Boolean, Integer, Long, or Variant, and properties corresponding to numeric input fields can be set by assigning variables of the appropriate type (e.g., Double for fields that accept floating point values). Refer to Editing and Customizing Recorded Macro (SVB) Programs for additional details.
.PairwiseDeletionOfMD = True
Instead of .PairwiseDeletionOfMd, you may see .CasewiseDeletionOfMD, or .MeanSubstitutionOfMD to denote the respective choice of how to handle missing data. As with all check boxes and option buttons, instead of True or False, you could also assign 1 or 0, respectively, to the properties, or you can assign a variable computed in some other part of a larger program.
This dialog contains two list boxes with several distributions to choose from. If you select the Normal distribution, the Fitting Continuous Distributions dialog is displayed.
Here you can still change to a different continuous distribution by selecting a different option in the Distribution list. The choices illustrated above would be recorded as follows:
Set newanalysis = Analysis (scDistributions) With newanalysis.Dialog
.FitContinuousDistributions = True .ContinuousDistribution = scNonNormal
End With newanalysis.Run With newanalysis.Dialog
.Variable = "6" .Distribution = scNonGamma '...
End With
Note the use of the symbolic constants scNonNormal and scNonGamma. These are constants that can be substituted by simple values to indicate relative position of the respective choices in the list of choices. So for example, scNonNormal is the first choice in the list of options in the Continuous distributions box in the Startup Panel; scGamma is the fourth choice in the list in the Fitting Continuous Distributions dialog. Because in SVB all enumerations, by default, begin with 0 (and not 1), you could replace these two constants with the values 0 and 3, respectively; so you could also write:
.ContinuousDistribution = 0 .Distribution = 3
The symbolic constants available in a particular dialog can be reviewed in the Object Browser.
Select the respective object library (note that the Distribution Fitting module is contained in the Nonparametrics library; see Statistica Libraries and Modules for a complete listing of analysis modules and libraries), select an Enumeration in the left panel, and then scroll in the right panel to the constants available for that enumeration.
Moving forward (clicking OK); moving backward (clicking Cancel); moving sideways. When running an analysis interactively, a sequence of dialoges is presented with options for each step of the analysis, and the user can move back and forth to make modifications as desired. Also in some cases, you can move "sideways" between dialogs; for example, in the Multiple Regression Results dialog, there is an option to move to the Review Descriptive Statistics dialog; once you Cancel out of that dialog, you will return to the Multiple Regression Results dialog. Shown below is a part of a typical macro recording those "movements," based on a recording of an analysis with the Multiple Regression module.
Set newanalysis = Analysis (scMultipleRegression) With newanalysis.Dialog
.RegressionMode = scRegLinearRegression .Variables = "5 | 6 7 8"
End With newanalysis.Run With newanalysis.Dialog
'.... '....
End With newanalysis.Dialog.ReviewDescriptiveStatistics With newanalysis.Dialog
'....
End With newanalysis.GoBack With newanalysis.Dialog
'...
End With newanalysis.Run With newanalysis.Dialog
'...
End With newanalysis.GoBack With newanalysis.Dialog
'...
End With
The newanalysis.Run method causes the program to "move forward"; in a sense the .Run method "clicks" the OK button. The statement newanalysis.Dialog.ReviewDescriptiveStatistics is the recording of a "sideways" move; in this particular instance, it moves from the Multiple Regression Results dialog to the Review Descriptive Statistics dialog. The newanalysis.GoBack method is the equivalent of clicking Cancel, and thus causes the analysis to "go back" to the previous dialog.
'...
With newanalysis.Dialog
'...
End With newanalysis.Dialog.ResultsVariables = "6 7" newanalysis.Dialog.ResultsSelection = "1 | 2 " newanalysis.Dialog.CategorizedMeansInteractionPlots._ Visible = True
Here the macro recorded the selection of results variables 6 and 7, and further ResultsSelection 1 and 2, i.e., when you run the program, the first element in the first list (of the two-list selection dialog) will be selected, and the second element in the second list.
When you click OK, the predicted value for these independent variable values are computed. When you record a macro to document this analysis, this results option is recorded as follows:
newanalysis.Dialog.ResultsValues = "1.5 3.5 4 " newanalysis.Dialog.PredictDependentVar.Visible = True