Hi
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
.AddCases(10,990)
Dim delta As Integer
delta=3*S0.NumberOfCases-10
If delta>0 Then
.AddVariables("Var",10,delta)
End If
.Activate
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
Xstr=Str(.Cells(index,1))
Ystr=Str(.Cells(index,2))
Zstr=Str(.Cells(index,3))
End With
With S1
.VariableLongName(3*index-2)="=VNormal(rnd(1);"+Xstr+";"+sigma+")"
.VariableLongName(3*index-1)="=VNormal(rnd(1);"+Ystr+";"+sigma+")"
.VariableLongName(3*index)="="+Zstr
.Recalculate(3*index-2)
.Recalculate(3*index-1)
.Recalculate(3*index)
End With
Next index
With S1
For index=2 To S0.NumberOfCases
.AddCases(1000*(index-1),1000)
Dim jndex As Integer
For jndex=1 To 1000
.Value(1000*(index-1)+jndex,1)=.Value(jndex,3*index-2)
.Value(1000*(index-1)+jndex,2)=.Value(jndex,3*index-1)
.Value(1000*(index-1)+jndex,3)=.Value(jndex,3*index)
Next jndex
Next index
.DeleteVariables(4,Max(3*S0.NumberOfCases,10))
.VariableName(1)="X"
.VariableName(2)="Y"
.VariableName(3)="Class"
End With
Dim res As Object
Dim newanalysis As Analysis
Set newanalysis=Analysis(scClusterAnalysis,S1)
With newanalysis.Dialog
.ClusterMethod = scCluKMeanAnalysis
End With
newanalysis.Run
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
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
.AddCases(10,990)
Dim delta As Integer
delta=3*S0.NumberOfCases-10
If delta>0 Then
.AddVariables("Var",10,delta)
End If
.Activate
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
Xstr=Str(.Cells(index,1))
Ystr=Str(.Cells(index,2))
Zstr=Str(.Cells(index,3))
End With
With S1
.VariableLongName(3*index-2)="=VNormal(rnd(1);"+Xstr+";"+sigma+")"
.VariableLongName(3*index-1)="=VNormal(rnd(1);"+Ystr+";"+sigma+")"
.VariableLongName(3*index)="="+Zstr
.Recalculate(3*index-2)
.Recalculate(3*index-1)
.Recalculate(3*index)
End With
Next index
With S1
For index=2 To S0.NumberOfCases
.AddCases(1000*(index-1),1000)
Dim jndex As Integer
For jndex=1 To 1000
.Value(1000*(index-1)+jndex,1)=.Value(jndex,3*index-2)
.Value(1000*(index-1)+jndex,2)=.Value(jndex,3*index-1)
.Value(1000*(index-1)+jndex,3)=.Value(jndex,3*index)
Next jndex
Next index
.DeleteVariables(4,Max(3*S0.NumberOfCases,10))
.VariableName(1)="X"
.VariableName(2)="Y"
.VariableName(3)="Class"
End With
Dim res As Object
Dim newanalysis As Analysis
Set newanalysis=Analysis(scClusterAnalysis,S1)
With newanalysis.Dialog
.ClusterMethod = scCluKMeanAnalysis
End With
newanalysis.Run
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