Hide empty Data Columns? - Statistica Visual Basic - Statistica - Dell Community

Hide empty Data Columns?

Hide empty Data Columns?

This question is not answered

After certain queries I have some empty data columns that I would like to hide or not show. I do not want to remove the variable from the query thus eliminating the column because sometimes the column will contain data. I just want to find a way to autohide a column if it contains no data.



All Replies
  • You could run a short SVB script and use spreadsheet's VariableExcluded or VariableWidth properties, depending on what type of hiding you need. If you need a quick way of checking which columns contain data there is a Statistics method of the same object.



  • I think that JoJo is on the right track.

    The only way to hide a variable is by using an SVB script to set the width with the Spreadsheet.VariableWidth() method.

    To check if all cases in the variable are empty, an SVB script would also be needed. You would loop through all cases in the variable and use the Spreadsheet.MissingData() method to check if each cell in that variable is empty.




  • The SVB code below shows a simpler way to detect empty variables using the Spreadsheet.Statistics() method. It also demonstrates how to set the width of a given variable to zero, thereby preventing that variable from being displayed:

    '#Language "WWB-COM"
    Option Base 1
    Option Explicit

    Sub Main
    'assign active data set to spreadsheet object
    Dim ss As Spreadsheet
    Set ss = ActiveDataSet

    'prevent empty variables in spreadsheet from displaying
    End Sub

    'prevent empty variables in spreadsheet from displaying
    'ss: spreadsheet in which empty variables will be prevented from displaying
    Sub cloakEmptyVariables(ss As Spreadsheet)
    'create arrays to hold results from Spreadsheet.Statistics() method
    Dim dMean() As Double
    Dim dSD() As Double
    Dim dMin() As Double
    Dim dMax() As Double
    Dim lNum() As Long

    'calculate common statistics for each variable, the "*" argument
    'indicates that values should be calculated for all variables
    'in the spreadsheet

    'check each variable to see if it is empty,
    'the value in the lNum() array is the number of non-empty
    'values in the given variable
    Dim i As Long
    For i = 1 To UBound(lNum)
    'if the variable is empty, then set its width to zero,
    If lNum(i) = 0 Then
    ss.VariableWidth(i) = 0
    End If
    Next i
    End Sub