Export & data

Tri-state projection

How coded questions with fan-out columns (`multi`, `gridMulti`, and their masked variants) project to the wide export. Each cell is one of three values — `1` shown-and-selected, `0` shown-and-not-selected, `null` not-shown — so analysts can tell "they rejected it" apart from "we never asked". Where masking, isolated options, and empty loops all resolve to `null`.

What tri-state means

A multi question (or gridMulti row, or any coded domain that fans out into one column per code) doesn’t store a simple 1 / 0 per column. Each cell is one of three values:

Cell valueMeaning
1The option was shown to the respondent and they selected it.
0The option was shown to the respondent and they did not select it.
nullThe option was not shown — masked out, hidden by an if:, or the containing loop iteration never ran.

The distinction between 0 and null is what makes downstream analysis honest. 0 is “seen and rejected”; null is “never even asked”. Collapse them together and every masked-option denominator lies.

The types this applies to

Tri-state is the projection rule for every fan-out column in the wide export:

  • multi — one column per option code.
  • gridMulti — one column per (row × scale-code).
  • multi / gridMulti fed by a shared/list-backed domain — same rule, the visible subset varies per respondent.
  • Domains narrowed by options.from: — options filtered out of an individual respondent’s view come back as null.
  • Grouped domains — a group whose members are conditionally unavailable projects the unavailable codes to null.

Single-column projections (single, open, number, numberList row, gridSingle row, gridNumber cell) don’t fan out and don’t need tri-state — they’re either a value or blank.

Worked example — a masked multi

Two respondents. Same authored domain QUsage: {1: Weekly, 2: Monthly, 3: Rarely, 4: Never}. But options.from: masks code 4 for anyone under 25.

- qid: QUsage
    type: multi
    text: Which of these apply?
    options: usageList
    options.from: mask_by_age.selected   # a script computes the visible codes
  • R1 (age 30, saw all four, selected 1 + 2):
    • QUsage_1 = 1, QUsage_2 = 1, QUsage_3 = 0, QUsage_4 = 0
  • R2 (age 22, saw only 1 / 2 / 3, selected 1):
    • QUsage_1 = 1, QUsage_2 = 0, QUsage_3 = 0, QUsage_4 = null

The under-25 sample denominator for “picked Never” is R2 (0 / 1), not any Rs with _4 == 0 — the null cell tells the analyst which respondents were never asked.

null from a skipped if:

A multi gated by an outer - if: block projects to all-null for respondents who didn’t take that branch — nothing was shown, so nothing was seen-and-rejected.

- if hEligible.value == 1:
    - qid: QUsage
        type: multi
        options: usageList

Ineligible respondents get QUsage_1 = null, QUsage_2 = null, QUsage_3 = null, QUsage_4 = null — one row’s worth of nulls, not four zeros.

Isolated options (“I don’t know”, “None”, …)

When an isolated option (e.g. 99: { label: Prefer not to answer, isolate: True, exclusive: True }) is active on a respondent’s answer, two things happen in the wide file:

  1. The question’s normal columns go null — the respondent’s real answer is cleared, so every row/scale/cell column projects to null.
  2. A single flag column is emitted naming the opt-out code: <qid>r<code> (or <qid>o<code> for rank, or <qid>c<code> for a gridNumber column-axis opt-out). The column reads 1 when the opt-out is active, otherwise blank.
TypeOpt-out flag columnLocation
open, number<qid>o<code> = 1One flag column; the scalar answer column is null
lookup (all modes)<qid>o<code> = 1One flag column; the value / field / cascading-step columns are null
openList, numberList<qid>r<code> = 1Inside the row-column block
rank<qid>o<code> = 1Inside the option-column block
gridNumber (row-axis)<qid>r<code> = 1Row-axis flag
gridNumber (column-axis)<qid>c<code> = 1Column-axis flag
gridSingle<qid>r<code> = 1One flag column, not in the row × scale cross product
gridMulti<qid>r<code> = 1One flag column, not in the row × scale cross product
mixGrid<parent>r<code> = 1On the parent qid, emitted last after every child column’s block

The flag column lets analysts count opt-outs directly (WHERE Qxr99 = 1) instead of inferring them from the null pattern across the row/scale columns.

Two distinct null causes still. A cell being null on the export can mean the option was masked out (never shown) OR the opt-out was active (shown, but the respondent chose "None of these"). Both roll through the tri-state null for the answer columns. The flag column disambiguates the second case: Qxr99 = 1 tells you the null was from an opt-out; otherwise it was from masking.
Prior contract. Before v3.36.1 the isolate flag was not emitted — analysts had to infer opt-outs from the null pattern. Exports produced before v3.36.1 will not have <qid>r<code> columns for their opt-outs; re-materialize if you need them.

Empty-loop projection

When a loop’s options.from: resolves to an empty collection, none of the loop body’s questions render, and their columns project to null (see Loop suffixes → What an unreached iteration exports). Same rule as an unshown option — cell was never presented, null is the honest value.

What null looks like in each format

The physical rendering of null depends on the output format:

FormatRenders null as
CSVEmpty cell — 1,,0,
XLSXEmpty cell — the analyst’s tool reads it as blank
SPSS .savSystem-missing (.)
SPSS .sps / .datBlank field in the data file; declared as system-missing in the syntax
ASCII (fixed-width)Blank characters at the field’s fixed width; the codebook declares the missing convention

The contract is identical across formats — the physical marker differs, the semantics don’t.

See also

  • Column naming — the fan-out rule that produces Qido1, Qido2 etc.
  • Loop suffixes — how null propagates to unreached iterations
  • Long format — an alternative shape where null cells become absent rows instead
  • Formats — how each output engine encodes null