Bar charts (simple, clustered, stacked) with error bars
Shows counts, percentages or a summary (mean, median, sum) of a variable for each category, optionally split by a second category into clustered or stacked bars, with confidence-interval, standard-error or standard-deviation error bars for means.
Menu: Graphs → More charts → Bar chart (clustered / stacked, error bars)…
When should I use it?
- Comparing mean scores across groups, with 95% confidence intervals.
- Showing how a categorical answer is distributed within each group (100% stacked bars).
What are the assumptions?
- Categories should be mutually exclusive.
- Error bars on means assume roughly normal sampling distributions (fine for moderate n).
How do I run it in StatLab?
- Put the category variable on the category axis.
- Optionally choose a variable to summarize (else bars show counts).
- Optionally add a cluster/stack variable and pick clustered or stacked.
- Choose error bars for means.
How do I read the output?
| Output | Meaning |
|---|---|
| Bars | One bar per category (and cluster); hover for the exact value and n. |
| Error bars | The interval named in the footnote, e.g. 95% CI of the mean. |
Worked example
On the practice survey dataset (File → Sample dataset), this command — which the dialog's Paste button also produces — runs the procedure:
PROC vizBar /x=group /y='' /color='' /stat=auto /mode=clustered /errorBars=ci /dataLabels=NO.
Computed by StatLab's validated procedure code when this page was built. The example only illustrates the steps; choose variables that fit your own research question.
What are common mistakes?
- Starting a bar axis above zero (bars then exaggerate differences).
- Reading overlapping 95% CIs as “no significant difference” — run the proper test.
- Using a stacked bar to compare middle segments; use clustered bars instead.