Desktop User Guides > Professional > Table scripting > Hierarchical data > Using the flat (VDATA) view
Using the flat (VDATA) view
Sample script file: QuanceptTables.mrs
This example script is based on the Museum sample Quancept data set. See Running the sample table scripts for information on running the example scripts.
When you use the flat (VDATA) view of the data, any hierarchical data is “flattened” and a separate variable stores the responses to each question in each possible iteration. When you use the flat view of the data, data in unbounded loops is unavailable because it cannot be flattened. For more information, see Loops, grids, and levels.
The flat view of the data is always used when the case data is stored in an IBM SPSS Statistics(.sav) or Quancept(.drs) file, regardless of whether you are using an .mdd file or reading the metadata directly from the .sav or .qdi file.
When you use the flat view of the data, you specify a variable for use in an axis or filter using the full name of the variable instance (VariableInstance object). You can use in an axis variables of the following data types only:
For all variables apart from categorical variables that have the properties defined below, at least one element must be defined, either in the Variable.AxisExpression MDM property or in the axis specification.
When you tabulate a categorical variable, the axis will contain all of the elements of the variable, unless an axis expression exists in the metadata or an element list is explicitly specified in the axis specification. When the axis is based on the variable's elements, the variable must have the properties shown in the following table.
Variable instance property
Valid setting for use in an axis
Must contain at least one Element object
The MDM Document.Variables collection provides a flat list of the variable instances that are available when you are using the flat (VDATA) view of the data. In the UNICOM Intelligence Professional Metadata Viewer, you can view the variable instances in the Document.Variables collection. To do this, double-click the Document's Variables folder. This opens a list of the VariableInstance objects. Each object is shown with an icon that indicates its type.
This graphic is described in the surrounding text.
You can use the Properties pane to copy the full name of a VariableInstance object in order to paste it into your script.
This graphic is described in the surrounding text.
For more information, see Using the metadata viewer.
You can access the MDM Document in your script using the DataSet.MDMDocument property. The following example loops through the variable instances in the Document.Variables collection and creates a frequency table for all categorical variables that have at least one element, and are not helper variables or part of a compound, block, grid, or loop:
Dim MyVariableInstance, MyCounter, MyTableName, MyTableSpec, MyTableDescription

MyCounter = 0

For Each MyVariableInstance in TableDoc.DataSet.MDMDocument.Variables
If MyVariableInstance.DataType = mr.Categorical _
And MyVariableInstance.Elements.Elements.Count > 0 _
And BitAnd(MyVariableInstance.UsageType, 31) = 0 Then ' Exclude grid, loop and helper variables
MyCounter = MyCounter + 1
MyTableName = "Table" + CText(MyCounter)
MyTableSpec = MyVariableInstance.FullName
MyTableDescription = MyVariableInstance.FullName
TableDoc.Tables.AddNew(MyTableName, MyTableSpec, MyTableDescription)
End If
See also
Hierarchical data