Spreadsheet.Statistics

This function computes descriptive statistics for the specified variable(s).

Syntax Parameters Return Value
Sub Spreadsheet.Statistics( _
    Vars As Variant, _
    ByRef Mean As Double(), _
    ByRef StdDev As Double(), _
    ByRef Min As Double(), _
    ByRef Max As Double(), _
    ByRef N As Integer())
  • Vars [in]

The variables to be used.

Type: Variant

  • Mean [out]

Array of Doubles where the mean values will be stored.

Type: Double()

  • StdDev [out]

Array of Doubles where the Standard Deviations will be stored.

Type: Double()

  • Min [out]

Array of Doubles where the Minimum values will be stored.

Type: Double()

  • Max [out]

Array of Doubles where the Minimum values will be stored.

Type: Double()

  • N [out]

Array of Longs where the valid number of cases for each variable will be stored.

Type: Integer()

This function does not return a value.

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