Spreadsheet.Statistics
This function computes descriptive statistics for the specified variable(s).
SVB Example
Computes descriptive statistics of variables:
Option Base 1 Option Explicit Sub Main Dim spr As Spreadsheet 'assigns the active spreadsheet to the object spr Set spr = ActiveSpreadsheet 'arrays used to hold the corresponding calculated statistics Dim Mean() As Double Dim StdDev() As Double Dim Minimum() As Double Dim Maximum() As Double Dim N() As Long 'computes descriptive statistics for variables 1-5 and stores them 'in the corresponding arrays spr.Statistics("1-5",Mean(),StdDev(),Minimum(),Maximum(),N()) Dim outputspr As Spreadsheet 'create a new spreadsheet to place the descriptive statistics into Set outputspr = Spreadsheets.New("Descriptive Statistics") 'sets the size of the spreadsheet outputspr.SetSize(UBound(Mean()),5) 'sets the variable names for the new spreadsheet outputspr.VariableName(1) = "Mean" outputspr.VariableName(2) = "StdDev" outputspr.VariableName(3) = "Min" outputspr.VariableName(4) = "Max" outputspr.VariableName(5) = "N" Dim i As Integer For i = 1 To UBound(Mean()) 'sets the case names for the outputspr equal to the input spreadsheet variable names outputspr.CaseName(i) = spr.VariableName(i) Next i 'places the data stored in the arrays into the corresponding variable outputspr.VData(1) = Mean() outputspr.VData(2) = StdDev() outputspr.VData(3) = Minimum() outputspr.VData(4) = Maximum() For i = 1 To UBound(N()) outputspr.Value(i,5) = N(i) Next i 'display the spreadsheet outputspr outputspr.Visible = True End Sub
Copyright © 2020. Cloud Software Group, Inc. All Rights Reserved.