Troubleshooting
Problem
I am using SPSS for Windows. I've displayed cases by running the Case Summaries procedure (Analyze->Reports->Case Summaries). I place at least one variable in the Variables box. The 'Display Cases' option is checked and 'Show Case Numbers' is unchecked in both the Statistics option and the main dialog box. I click OK. I notice that the Case Summaries table contains a listing of case numbers despite my requests. Why is this occurring?
Resolving The Problem
This feature request has been reported to SPSS Development for remediation in a future release. In the meantime, the following script should assist you:
1. Highlight the script below and click Edit->Copy.
2. Next, click File->New->Script.
3. Click Cancel.
4. Delete any visible text.
5. Click Edit->Paste.
6. Next, click File->Save As and save the script using a name such as, 'RemoveCaseNumbers.sbs'.
7. Exit the script window.
In the Output window, select the Case Summaries table. Click Utilities->Run Script. Locate the saved script. Click Run. You should notice the case numbers are no longer present. In addition, the width of the column of the case numbers is reduced. Unfortunately, it is not possible to remove the column of case numbers through scripting because such a task is not possible manually.
'__________________________________________________________________________
'Begin Description
'This script assumes that a Summarize (Case Summaries) Pivot table is selected
'For the selected Pivot table, this script will search the
'first column for case numbers and remove them
'For the selected Pivot table, this script adjusts the column to the smallest
'available width, but cannot completely remove the column
'End Description
Option Explicit
'Here we declare a constant to store a very large case number that we know does
'not exist in the file
Const cVAL = "1000000"
Sub Main
Dim objSelPivotTable As PivotTable
Dim objItem As ISpssItem
Dim bolFoundOutputDoc As Boolean
Dim bolPivotSelected As Boolean
'Get the selected pivot table
Call GetFirstSelectedPivot (objSelPivotTable, objItem, bolFoundOutputDoc, bolPivotSelected)
If (bolFoundOutputDoc = False) Or (bolPivotSelected = False) Then
'either there was not an output doc or a pivot table was not selected
Exit Sub
End If
Call RemoveCaseNumbers (objSelPivotTable)
'RemoveCaseNumbers is the subroutine that will search for the specified
'range of case numbers in the first column of the Case Summaries table
'and remove them It will also adjust the column width, accordingly,
'but will not be able to remove the column completely
objItem.Deactivate
End Sub
Sub RemoveCaseNumbers (objPivotTable As PivotTable)
Dim objRowLabels As ISpssLabels
Dim objColLabels As ISpssLabels
Dim lngRowNum As Long
Dim lngColNum As Long
'Here we get the row labels (which store the case numbers)
Set objRowLabels = objPivotTable.RowLabelArray ()
For lngRowNum = 0 To objRowLabels.NumRows - 1
For lngColNum = 0 To objRowLabels.NumColumns - 1
If Not (IsNull(objRowLabels.ValueAt(lngRowNum,lngColNum))) Then
'Here we use an IF statement and state that if the case number is not equal to the cVAL defined above,
'replace it with a blank as denoted by the double quotation marks
If (objRowLabels.ValueAt(lngRowNum,lngColNum)) <> cVAL Then
objRowLabels.ValueAt(lngRowNum, lngColNum)= " "
'Now adjust for the re-sized row labels by decreasing the row label width
'Unfortunately, we cannot get rid of the column completely in that this is
'not possible manually
objRowLabels.RowLabelWidthAt (lngRowNum, lngColNum) = 1
End If
End If
Next lngColNum
Next lngRowNum
objPivotTable.UpdateScreen = True
End Su
Related Information
Historical Number
41639
Was this topic helpful?
Document Information
Modified date:
16 April 2020
UID
swg21474836