We’ve had a few goes at the perfect approach to scripted reports, but I think that this is it. If anyone reckons they have a better way, please let it be known. The general framework (using VB.Net) is

' Global Declarations 
Public name As String = "" ' report name for TOC
Public top As String = "Gender,Occupation,Married" ' top axis
Public side As String = "" ' side axis
Public filt As String = "" ' report filter
Public wght As String = "WghtAgeGenRegRim()" ' report weight
' global case filter (must be a simple filter on a single-response variable)
Public casefilt As String = "Region(1)" 
Public TOCparent As String = "Standard Tables" ' parent folder in TOC

Sub Reports()

   SetTemplateTable("Template_SmallFonts")
   NoWindow(true)
   CaseFilter(casefilt)

   ' Override default template table properties
   rub.SetTableProp("ColumnPercents", "Visible", true)
   rub.SetTableProp("Frequencies", "Visible", true)
   rub.SetTableProp("RowPercents", "Visible", true)
   '' etc for other properties as required
   ClearRAM()
   ' Call sub-routines
   RunDemogs()
   '' etc for other subroutines as required

End Sub

Sub RunDemogs()

   '' same for all reports in this subroutine, so assign once here
   filt = "Week(100/200)"

   name = "srAge"
   side = "Age(*;#)%<Respondent Age>"
   Run()

   name = "srOccupation"
   side = "Occupation"
   Run()

   name = "srHousehold"
   side = "Household"
   Run()

   SaveAllAndTOC(TOCparent & "/" & "Demographics")
   ClearRAM

End Sub

' Generate the table from the assigned parameters
Sub Run()
   GenTab(name, top, side, filt, wght)
End Sub

This fits in well with the new Generate Spec on the TOC right mouse menu:

You copy/paste the first four lines to your script, and then remove any unwanted bits which are already defined as you want, then add the Run() call.

name = “demBrandAwa”
side = “UBA(1/10)”
Run()

If you want to save on screen footprint, the above can be done as a single line using colons like this:

name = “demBrandAwa” : side = “UBA(1/10)” : Run()

Categories:

Tags:

Comments are closed