Clean and Define - Operations

Structure Operations

A Structure operation consists of two sub operations, Select and Create, which can be combined in any order. These operations will select a subset of all questions and add new questions that later can be filled with data.
Select selects and/or rearranges questions from the input dataset and optionally assigns new identifiers (id/qno), transposes, concatenates or converts questions or combines components (logical OR). Create creates new questions. If any of these operations are used, the output dataset will contain only the selected or created questions and subsequent groups and weights operation will only be able to use these questions. The Structure operation should be omitted if you want to keep all questions.

Examples

All examples assume we have a dataset with questions having labels Q1 to Qn, where n is the number of questions.

  • Select one or more questions and rearrange the order of questions.
    Select Q1, then Q6, then question Q3 to Q5:
<select a=”\Q1,Q6,Q3,,Q5” />
  • Select one or more sub questions and rearrange the order of sub questions.
    Select sub question B, then E, then A. All other sub questions in Q1 are removed:
<select a=”\Q1.b,e,a” />
  • Select one or more rows and rearrange the order of rows.
    Select the third row, then the first and then rows 4 to 8. Rows 2 and 9 are removed if the question has 9 rows.
<select a=”\Q1.3,1,2,4,,8” />
  • Select one or more columns of a grid question and rearrange the order of columns.
    Select, from row 1 to 5, first column 3, then 2, then 1, then 4 to 6:
<select a=”\Q1.a.1,,5[3,2,1,4,,6]” />
  • Select and insert empty rows and columns.
    When inserting rows and columns, new code sequences are generated (1, 2, 3…).
    Select the first 3 rows, then insert an empty row, then select column 1 to 3 and finally insert an empty column:
<select a=”\Q1.a.1,,3,![1,,3,!]”/>
  • Transpose. Create a question with multiple sub questions from a grid question.  Each row in the grid will form a new multi or single sub question. Each column in the grid will create a new row.
<select a=”\Q5.a” transpose=”true” />
  • Convert. Create a question with multiple multi sub questions from a grid. Each grid column will form a new multi sub question.
<select a=”\Q3.a” convert=”true” />
  • Convert. Create a multi grid question from multiple single/multi questions. Each sub question will form a grid column.
<select a=”\Q4.a,b,d” convert=”true” />
  • Concatenate rows from many questions into one question.
    Create a new question with label Q1 with all rows from Q2 and Q4 appended.  New code sequences are generated for multi and single questions (1, 2, 3…).
    Rules:
    All questions must have the same structure (same type, number of sub questions, and number of columns). qtext and subq are kept from the first question. All rows and row comments are appended from the rest of the concatenated questions
<select a=”\Q1,Q2,Q4” concat=”r” />
  • Concatenate sub questions from many questions into one.
    Create a new question with all sub questions from Q3 and Q5 added to Q1. Finally set the question label to newId.
    Rules:
    All questions must have the same number of rows. Row texts are taken from the first question. 
<select a=”\Q1,Q3,Q5” concat=”s” id=”newId”/>
  • Combine rows.
    Select row 1, then 3, then ‘OR’ row  4 to 6 into a new row, then select row 8, then ‘OR’ row 7, 9 and 10 into a new row.
    Rules:
    Single/Multi (n/m)with a single question (n) this could lead to multiple answers. Q-bit is left as is, R-bit is set if at least one answer is in final output. A new code sequence is created (1, 2, 3…).

    Grid single/multi (rn/rm) with a single grid question (rn) it is very likely that the result will be multiple answers. Q-bits should be an ‘OR’ of each ‘OR’ed row’s Q-bits. R-bit should be set if at least one answer in the row. 

    Numeric/Time (f/h)with a numeric or time question (f/h) values from each row are added.  Q-bits should be an ‘OR’ of each ‘OR’ed row’s Q-bits and the same with the R-bits.

    Commontext for a combined row is constructed as a string with a copy of the ‘OR’ operation performed. E.g. from the example, texts for the two created rows are ‘4:5’ and ‘7;9;10’
<select a=”\Q1.a.1,3,4:6,8,7;9;10” />
  • Combine columns.
    Select column 2, then 1, then ‘OR’ column 3 and 4, then ‘OR’ column 7 and 10.
    Rules:
    text for a combined column is constructed as a string with a copy of the ‘OR’ operation performed. E.g. from the example, texts for the two created columns should are ‘3:4’ and ‘7;10’
<select a=”\Q1.a[2,1,3:4,7;10]” />
  • Combine single/multi sub questions.
    The new sub question will be based on the first sub question and  the type will be set to multi (m).  All rows will be joined (version 1).
    Q-bits are calculated as an ‘OR’ of the sub questions’ Q-bits. R-bit is set if at least one answer in the new sub question.  A-bits are calculated as an ‘OR’ of the A-bits in each row.
    Rules:
    all texts are from the first sub question. In version 1, all rows will be joined and it is not possible to select a subset of rows.
<select a=”\Q1.b:c” />
  • Create new questions
    A Create operation can contain one or more <ques> elements (uses the same syntax as qdoc).
<?xml version="1.0" encoding="UTF-8"?>
<create>
   <ques id="L1">
      <subq type="m">
         <stext>
            <text lang="en">Which brands do you know?</text>
         </stext>
      </subq>
      <rgroup>
         <r>
            <text lang="en">Volvo</text>
         </r>
         <r>
            <text lang="en">Saab</text>
         </r>
         <r>
            <text lang="en">Ford</text>
         </r>
      </rgroup>
   </ques>
   <ques id="L2">
      <subq type="rn">
         <stext>
            <text lang="en">How would you rate</text>
         </stext>
         <hgroup>
            <h>
               <text lang="en">Good</text>
            </h>
            <h>
               <text lang="en">Bad</text>
            </h>
         </hgroup>
      </subq>
      <rgroup>
         <r>
            <text lang="en">Volvo</text>
         </r>
         <r>
            <text lang="en">Saab</text>
         </r>
         <r>
            <text lang="en">Ford</text>
         </r>
      </rgroup>
   </ques>
</create>

Select and Create can be combined in any order. Questions and components can also be part of many operations. For example, a question with two sub questions can be split into two questions and the same question can later be part of another operation:

<?xml version="1.0" encoding="UTF-8"?>
<structure>
   <select a="\Q1.a" />
   <select a="\Q1.b" />
   ...
   <select a="\Q1,,Q3.a" />
   <create>...</create>
</structure>

Still need help? Contact Us Contact Us