Change Sig to P
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | 'Begin Description 'This script changes "Sig." to "p=" in the column labels of any pivot table. 'Requirement: The Pivot Table that you want to change must be selected. 'End Description 'PURPOSE 'This script changes "Sig." to "p=" in the column labels of any pivot table 'ASSUMPTIONS 'A pivot table that contains "Sig." in one or more column labels is selected in the Navigator. 'Also, the Navigator (Output Document) that contains the Pivot Table is the Designated Output Window 'EFFECTS 'Changes "Sig." to "p=" in the column labels of any pivot table 'HINTS 'If you are new to programming, select Scripting Tips from the 'Help menu for a basic introduction. 'For information on SPSS automation objects, properties and methods, 'press F2 to display the Object Browser. 'For context-sensitive help on Sax Basic terms as well as SPSS objects, 'properties, and methods, press F1. Option Explicit 'All variables must be declarated before being used 'Script level constant declarations Const cSIG As String = "Sig." Const cP_EQUAL As String = "p=" '*********************************************************************** Sub Main 'Declare variables here Dim objPivotTable As PivotTable Dim objItem As ISpssItem Dim bolFoundOutputDoc As Boolean Dim bolPivotSelected As Boolean 'The following procedure is a global procedure that is located in global.sbs Call GetFirstSelectedPivot(objPivotTable, objItem, bolFoundOutputDoc, bolPivotSelected) If (bolFoundOutputDoc = False) Or (bolPivotSelected = False) Then 'either there wasn't an output doc or a pivot table wasn't selected Exit Sub End If Call CrosstabsSigToP(objPivotTable) 'CrosstabsSigToP changes "Sig." to "p=" objItem.Deactivate End Sub '********************************************************************** Sub CrosstabsSigToP(objPivotTable As PivotTable) 'Purpose: Changes column label that refer to significance 'Assumptions: A Pivot Table that contains "Sig." in one of the column labels is selected 'Effects: Any column label containing "Sig." will be replaced with "p=" 'Inputs: Selected Pivot Table 'Return Values: The Pivot Table with changed column labels 'Declare SPSS-specific objects Dim objColLabels As ISpssLabels 'Declare various integer indices Dim lngRowNum As Long Dim lngColNum As Long Dim lngNumCols As Long Dim lngNumRows As Long Set objColLabels = objPivotTable.ColumnLabelArray() lngNumCols = objColLabels.NumColumns lngNumRows = objColLabels.NumRows 'Check the last label in each row of column labels For lngRowNum = 0 To lngNumRows - 1 For lngColNum = 0 To lngNumCols - 1 If InStr(objColLabels.ValueAt(lngRowNum,lngColNum), cSIG) > 0 Then objColLabels.ValueAt(lngRowNum,lngColNum) = cP_EQUAL End If Next lngColNum Next lngRowNum End Sub '******************************************************************* |
Related pages
...
Navigate from here