This STATISTICA macro doesn't work. Help!


Help me please with this. My STATISTICA macro doesn't work. Here is its code. The problem is that STATISTICA gives an error when setting newanalysis.Dialog options. It outputs "no such property" error for ".NumberofClusters". What's wrong with that ? I suspect that the property is on additional options page for analysis dialog. But why is this
a problem ?

Option Base 1
Sub Main

Dim S0 As Spreadsheet, S1 As Spreadsheet

Set S0=Spreadsheets.Open("C:\Users\Kostya\Desktop\centers.sta")
Set S1 = New Spreadsheet

With S1

Dim delta As Integer

If delta>0 Then
End If


End With

Dim index As Integer
Const sigma="1,5"

For index=1 To S0.NumberOfCases

Dim Xstr As String, Ystr As String, Zstr As String

With S0


End With

With S1



End With

Next index

With S1

For index=2 To S0.NumberOfCases


Dim jndex As Integer

For jndex=1 To 1000


Next jndex

Next index


End With

Dim res As Object
Dim newanalysis As Analysis
Set newanalysis=Analysis(scClusterAnalysis,S1)

With newanalysis.Dialog
.ClusterMethod = scCluKMeanAnalysis
End With


With newanalysis.Dialog

.CasesOrVariables = scCluCases
.Variables = "1-2"
.NumberOfClusters = 2
.NumberOfIterations = 10
.CasewiseDeletionOfMD = True
.ConstantIntervals = True
.BatchProcessingAndPrinting = False

End With

Set res=newanalysis.Dialog.Summary

End Sub


New Member
In terms of your STATISTICA VB code, I'd recommend declaring and using variables (e.g., oAD1, oAD2, oAD3) for your analysis dialog objects.

Between lines "Set newanalysis=Analysis(scClusterAnalysis,S1)" and "End Sub", replace existing code with the following:

'Clustering Method dialog
Dim oAD1 As STACluster.CluStartup
Set oAD1 = newanalysis.Dialog
oAD1.ClusterMethod = scCluKMeans


'Cluster Analysis: K-Means Clustering dialog
Dim oAD2 As STACluster.CluKMeansSpecifications
Set oAD2 = newanalysis.Dialog
With oAD2
.CasesOrVariables = scCluCases
.Variables = "1-2"
.NumberOfClusters = 2
.NumberOfIterations = 10
.CasewiseDeletionOfMD = True
.ConstantIntervals = True
.BatchProcessingAndPrinting = False​
End With


'kMeans Clustering Results dialog
Dim oAD3 As STACluster.CluKMeansResults
Set oAD3 = newanalysis.Dialog
Set AO = newanalysis.RouteOutput(oAD3.ClusterMeansEuclideanDistances)
AO.Visible = True
If AO.HasWorkbook Then
Set AWB = AO.Workbook​
Set AWB = Nothing​
End If

I'm assuming that with "Set res=newanalysis.Dialog.Summary" you are trying to display the results summary.

Hope this helps.
Last edited:

I've got useful (and simple) answer from StatSoft that finally has hepled.
To fix the problem one should include the "Cluster Analysis" library
declaration in "Function libraries" page. When starting recording macro STATISTICA does it automatically but for general purpose macro it should be done manually.