> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sprig.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Cross Tab Analysis Across Segments

*Break a survey metric down by segment and verify the numbers before reporting them. This example has been tested and validated with Claude.*

<Card title="When to use this:" type="info">
  * A stakeholder asks whether a result holds for a specific segment. 
  * A metric needs comparison across plan tiers or company sizes. 
  * A topline number feels like it's hiding something once you consider who's behind it.
</Card>

This prompt handles rating-scale, yes/no, and other categorical outcomes. For open-ended responses that need to be themed first, see the [<u>advanced cross-tab guide</u>](/docs/native-ai/cross-tab-analysis-1)<u>.</u>

<Tip>
  For a detailed walkthrough of plain vs. engineered prompts on the same dataset, including a side-by-side comparison of where a plain prompt silently under-reports by 7–17 percentage points, see the [full cross-tab guide](https://sprig.com/guides/cross-tab-analysis-with-claude-simple).
</Tip>

## Prompt

<Note>
  Replace \[OUTCOME VARIABLE], \[SEGMENT VARIABLE(S)], and \[N] with your own column names and threshold.
</Note>

```text expandable lines theme={null}
I have a survey dataset with a categorical or rating-scale outcome
question and one or more segment/attribute variables (for example,
plan tier, company size, department, or customer segment). I want to
run a cross-tab analysis.

What this prompt does:
- Compares [OUTCOME VARIABLE] across the segments you specify
- Checks whether any segment has enough respondents to draw a real
  conclusion from

What it returns:
- A table of counts and percentages (or means, for rating-scale
  questions), broken out by segment
- A list of any segment comparisons that don't have enough data to trust
- A plain-language summary of the differences worth paying attention to
- A saved image of the table you can download and reuse

Please:
1. Cross-tab [OUTCOME VARIABLE] against [SEGMENT VARIABLE(S)]. These are
   column headers from your data file, exactly as they appear in the
   header row, like `plan_tier` or `nps_score`. They are not spreadsheet
   cell references or column letters, like "C" or "G2". For a
   categorical outcome, show counts and row percentages. For a
   rating-scale or numeric outcome, show the mean and the full
   distribution across scale points.
2. Use code to calculate this, not estimation. Exclude any missing,
   blank, or non-response values from the calculations rather than
   treating them as zero.
3. Flag any cross-tab cell with fewer than [N, e.g., 10] respondents. A
   cell with ZERO respondents also counts as under the threshold, not
   just small nonzero counts. Report the total flagged as a single
   number computed directly from the full table, not calculated in
   parts and combined.
4. Before giving me the final answer, recompute every number you're
   about to report directly from the underlying table one more time,
   using a genuinely different method than you used the first time,
   for example a manual count instead of a formula-based one. Simply
   re-running the same calculation again doesn't count as a check.
   Correct anything that doesn't match rather than keeping your
   first-draft number.
5. Summarize 2-3 patterns, and be explicit about which differences look
   meaningful versus likely noise given sample size. Don't overstate
   findings from a small dataset.
6. Save the table itself as an image file I can download, formatted so
   it's easy to read at a glance.
```

## Setup

**Code execution must be enabled** for step 4's verification to run. It's on by default for Team and Enterprise accounts. Free, Pro, and Max users: enable it under **Settings > Capabilities**.

<Tip>
  If your survey data lives in Sprig, skip the export, the [<u>Sprig MCP</u>](/docs/native-ai/sprig-mcp) connects live surveys and responses directly into Claude so the analysis runs on current data.
</Tip>

## How it works

<Steps>
  <Step title="Cross-tabulate">
    Compares your outcome variable across each segment. Rating-scale outcomes return a mean and full distribution. Categorical outcomes return counts and row percentages.
  </Step>

  <Step title="Exclude non-responses">
    Missing, blank, and non-response values, including markers like "SKIPPED”,  are dropped before any calculation runs. This is explicit in the prompt, not left to default handling.
  </Step>

  <Step title="Flag thin cells">
    Any segment cell below your threshold (e.g., 10 respondents) is flagged, including cells with zero respondents. The total flagged count is computed from the full table at once, not assembled from parts.
  </Step>

  <Step title="Independent verification">
    Every number is recomputed using a genuinely different method before it's reported. Re-running the same calculation doesn't qualify as a check.
  </Step>

  <Step title="Plain-language summary">
    2–3 patterns, with explicit notes on which differences are meaningful versus likely noise given the sample size.
  </Step>

  <Step title="Exportable table">
    The final table is saved as a downloadable image, formatted for quick reading.
  </Step>
</Steps>

## Verify your own results

The built-in checks catch a lot, but spot-check before you publish or present:

* **Do group sizes add up?** Sum the segment counts and compare to your full dataset.
* **Does at least one number match a manual check?** Run a filter or pivot table on one percentage or mean.
* **Are any segments very small?** Treat anything reported for them as unreliable, even if not explicitly flagged.

<Warning>
  A calculation that runs without an error isn't the same as one that's correct. Ask explicitly what should and shouldn't be excluded,  don't rely on an absence of errors as confirmation.
</Warning>
