Dim resPortfolio As Portfolio Dim ProfileRow as Profile ' Define a profile of row questions to add to Dim ProfileCol as Profile ' Define a profile of column questions to add to Dim resItem As PortfolioItem ' Set the wave response numbers for previous & current waves Dim numPrevWave = ^Wave^.Responses.Count-2 Dim numCurrWave = ^Wave^.Responses.Count-1 ' Create sub-pops for current and previous waves Dim spPrevWave As SubPopulation spPrevWave.Name = "Previous Wave" spPrevWave.Script = "Wave.Value Has " + numPrevWave.ToString() spPrevWave.Save() Dim spCurrWave As SubPopulation spCurrWave.Name = "Current Wave" spCurrWave.Script = "Wave.Value Has " + numCurrWave.ToString() spCurrWave.Save() Dim h For h = 1 to Survey.Questions.Count ' Iterate through every question of the survey Dim currQuestion = Survey.Questions[h] Dim arrResponses = {} Dim qFlag = False 'Define question types to include/exclude Dim nonChap = currQuestion.Type <> "chapter" Dim nonOpn = currQuestion.Type <> "open" Dim nonCod = currQuestion.IsCoding = False Dim isVis = currQuestion.IsVisibleDuringDataEntry = True Dim isNum = currQuestion.Type = "numeric" Dim isScl = currQuestion.IsScaled = True Dim arrFactoredResponses = {} ' Only for non-chapters, non-open, visible, non-coding questions which are numeric (incl. sclaed closed questions) If nonChap and nonOpn and isVis and nonCod and (isNum or isScl) Then Dim i For i = 1 to currQuestion.Responses.Count-1 ' Iterate through every response of the current question If Abs(currQuestion.Responses[i].Factor) >= 0 Then ' only select responses which have a scaled value arrFactoredResponses = arrFactoredResponses + i Endif Next i ' Define the elements of the col sig formula 'Classical Student Test' ' (https://support.askia.com/hc/en-us/articles/207580509-Programming-Col-Sig-means-Classical-Student-Test-with-and-without-estimator-) Dim numX1 Dim numSD1 Dim numX2 Dim numSD2 Dim dN1 Dim dN2 If isScl Then ' Define elements specifically for scaled, closed questions numX1 = currQuestion.Data.MakeNumeric().Filter(spPrevWave.Name).Mean() numSD1 = currQuestion.Data.MakeNumeric().Filter(spPrevWave.Name).StdDev() numX2 = currQuestion.Data.MakeNumeric().Filter(spCurrWave.Name).Mean() numSD2 = currQuestion.Data.MakeNumeric().Filter(spCurrWave.Name).StdDev() dN1 = currQuestion.Data.Filter(spPrevWave.Name).Counts(arrFactoredResponses)[1] dN2 = currQuestion.Data.Filter(spCurrWave.Name).Counts(arrFactoredResponses)[1] Else ' Define elements specifically for open numeric questions numX1 = currQuestion.Data.Filter(spPrevWave.Name).Mean() numSD1 = currQuestion.Data.Filter(spPrevWave.Name).StdDev() numX2 = currQuestion.Data.Filter(spCurrWave.Name).Mean() numSD2 = currQuestion.Data.Filter(spCurrWave.Name).StdDev() dN1 = currQuestion.Data.Filter(spPrevWave.Name).Size() dN2 = currQuestion.Data.Filter(spCurrWave.Name).Size() Endif Dim DA1 = (numSD1*numSD1)/dN1 Dim DA2 = (numSD2*numSD2)/dN2 Dim numNumerator = numX1 - numX2 Dim numDenom = pow((DA1 + DA2),0.5) Dim tValue = numNumerator / numDenom If abs(tValue) > 1.96 Then ' Test at 95% (normal level) qFlag = True ' Set the flag true to select only the questions showing sig difference between current/previous wave Endif Endif If qFlag = True Then ProfileRow.Add(currQuestion) ' Add the question to the row question profile Endif Next h ' Add Wave to columns with only previous & current waves selected Dim arrWaveCurrPrev = {}.Push(numPrevWave).Push(numCurrWave) ProfileCol.Add(^Wave^,arrWaveCurrPrev) resItem.SetType(1) resItem.SetTitle("Simple Holecount - TEST") resItem.TabDef.Title = "??R?? x ??C??" resItem.TabDef.ReadTabTemplate("Askia2b") resItem.TabDef.SetUniverse(-3) resItem.TabDef.ReadTabStyle("Regal") resItem.TabDef.Rows.add(ProfileRow) ' Add the profile to the rows of the tab definition resItem.TabDef.Columns.add(ProfileCol) ' Add the profile to the columns of the tab definition resPortfolio.Add(resItem) ' Add the tab definition to the portfolio resPortfolio.Save(Survey.Directory + "Col Sig (means) Selection Holecount by Wave") resPortfolio.Open()