graph pyramid
Two sets of bars back to back, the classic population pyramid. Age bands up the middle, one sex on each side.
What we have
- statistics:
count,max,mean,median,min,sum over()for the categories andby()for a second splittitle(),ytitle()andsaving()- one self-contained
.htmlfile: no server, no internet, nothing to install - a table view beside the chart, so the numbers can be read off
Coming later
- saving as PNG or SVG —
graph exportdoes not exist yet graph twowayandgraph matrix, which are refused- 84 more of the 105 catalogue chart types
How you write it
graph pyramid [(stat)] [varname] [if] [weight], over(bandvar) by(sidevar)
Two back-to-back sets of bars. Counts people if you give no variable. by() must have exactly two groups.
What your data has to look like
One row per person or record, with these columns (named here as they are in vira.sample01):
| Column | Holds | What it does in the chart |
|---|---|---|
ageband | a category | the bands up the middle, youngest at the bottom (over) |
sex | a category | exactly two values: the left and right sides (by) |
mpce | a number | optional: total it; leave it out to count people |
Three rows of it would look like this:
15-27 Male 2410.55 15-27 Female 2298.2 28-40 Male 3102.8
The example
. sysuse vira.sample01, clear . graph pyramid, over(ageband) by(sex)
That is the real file the command wrote — open it on its own. It is one self-contained page with no internet connection needed, so you can email it or drop it into a report.