This article contains a sample script for calculating statistics in the worksheet window.

To run this script:

- Copy the script below, or download the attached WksStatistics.BAS file.
- In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Grapher 12\Scripter.
- Double click on Scripter.exe to launch Scripter.
- Press Ctrl+A to select all of the existing lines then press Delete.
- If you copied this script, press Ctrl+V to paste it into Scripter. If you downloaded it, click
**File | Open**, select the BAS file from your downloads directory, and click*Open*. - Click
**Script | Run**to run the script.

***********

Sub Main 'Declare the variable that will reference the application Dim GrapherApp As Object Set GrapherApp = CreateObject("Grapher.Application") GrapherApp.Visible = True 'Declares Wks As an Object Dim Wks As Object 'Opens a data file in the worksheet Set Wks = GrapherApp.Documents.Open(GrapherApp.Path+"\samples\bar chart orientations.dat") 'Declares WksRange as an object Dim WksRange As Object 'Assigns columns A, B and C to the variable named "WksRange" Set WksRange = Wks.Columns(1, 3) 'Uses the WksRange object statistics method to store statistics for columns A, B and C. Set Stats = WksRange.Statistics(True, True, wksStatsAll) 'Returns the number of columns for which the statistics are stored Debug.Print "Number of columns: "; WksRange.ColumnCount 'Returns the Average Deviation statistic value for columns A, B and C. Debug.Print "Average Deviation, colA: "; Stats.AverageDeviation(1) Debug.Print "Average Deviation, colB: "; Stats.AverageDeviation(2) Debug.Print "Average Deviation, colC: "; Stats.AverageDeviation(3) 'Returns the first row, last row, column label, number of values, and missing values used from column C Debug.Print "First Input Row: "; Stats.FirstRow(3) Debug.Print "Last Input Row: "; Stats.LastRow(3) Debug.Print "Label: "; Stats.Label(3) Debug.Print "Number of Values, colC: "; Stats.Count(3) Debug.Print "Number of Missing Values "; Stats.Missing(3) 'Returns the other statistic values for column C Debug.Print "Sample Coefficient of Variation "; Stats.CoefficientOfVariation(3) Debug.Print "Sample 95% Confidence Interval for the Mean "; Stats.ConfidenceInterval95(3) Debug.Print "Sample 99% Confidence Interval for the Mean "; Stats.ConfidenceInterval99(3) Debug.Print "First Quartile (25th percentile) "; Stats.FirstQuartile(3) Debug.Print "Critical Value of the K-S Statistic at 90% "; Stats.KSCriticalValue90(3) Debug.Print "Critical Value of the K-S Statistic at 95% "; Stats.KSCriticalValue95(3) Debug.Print "Critical Value of the K-S Statistic at 99% "; Stats.KSCriticalValue99(3) Debug.Print "Sample Kolmogorov-Smirnov Goodness of Fit "; Stats.KSStatistic(3) Debug.Print "Sample Kurtosis "; Stats.Kurtosis(3) Debug.Print "Maximum "; Stats.Maximum(3) Debug.Print "Mean "; Stats.Mean(3) Debug.Print "Median "; Stats.Median(3) Debug.Print "Minimum "; Stats.Minimum(3) Debug.Print "Range "; Stats.Range(3) Debug.Print "Sample Skewness "; Stats.Skewness(3) Debug.Print "Sample Standard Deviation "; Stats.StandardDeviation(3) Debug.Print "Sample Standard Error of the Mean "; Stats.StandardError(3) Debug.Print "Sum "; Stats.Sum(3) Debug.Print "Third Quartile (75th percentile) "; Stats.ThirdQuartile(3) Debug.Print "Sample Variance "; Stats.Variance(3) End Sub

*Updated October 28, 2016*

## 0 Comments