pyramid_chart
pyramid_chart is a stata user-generated package that produces a population pyramid.
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.8%) to scientific vocabulary
Keywords
Repository
pyramid_chart is a stata user-generated package that produces a population pyramid.
Basic Info
- Host: GitHub
- Owner: masud90
- License: mit
- Language: Stata
- Default Branch: main
- Homepage: https://masud90.github.io/pyramid_chart/
- Size: 36.1 KB
Statistics
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
- Releases: 2
Topics
Metadata Files
README.md
Population Pyramid Chart in Stata
This repository contains the pyramid_chart ado file for creating population pyramid charts in Stata. The pyramid_chart program allows you to create informative population pyramids, a type of graph that shows the distribution of a population by age groups and sex.
Features
- Generates population pyramids based on numeric and categorical variables.
- Allows customization of decimal places for percentage labels.
- Supports additional
twowaygraph andscattergraph options for further customization.
Installation
To install the pyramid_chart program, download the pyramid_chart.ado and pyramid_chart.sthlp files and place them in your Stata ado directory or your working directory. You can find or set your Stata ado path using the adopath command in Stata.
Options
The pyramid_chart program supports additional options that can be passed to the twoway graph command for further customization. All options for twoway in stata should work, with the exception of legend(), xlabel, ylabel which are produced using existing labels from the variables passed into the syntax.
Example
Here is an example of how to use the pyramid_chart program:
Pre-analysis:
While reshaping is not required before producing a pyramid chart, it is important that the data is in long format before it is fed into the pyramid_chart command. As an illustration, the following code reshapes the system-included pop2000.dta dataset into a long dataset containing the three required variables: population, sex, and agegrp.
sysuse pop2000.dta, clear
keep agegrp maletotal femtotal
rename maletotal population1
rename femtotal population2
reshape long population, i(agegrp) j(sex)
label define sexlbl 1 "Male" 2 "Female"
label values sex sexlbl
label variable population "Population"
label variable sex "Sex"
describe
| Variable name | Storage type | Display format | Value label | Variable label | |---------------|--------------|----------------|-------------|----------------| |agegrp|float|%12.0gc|agelbl|Age group| |sex|byte|%10.0g|sexlbl|Sex| |population|float|%12.0gc|-|-|
Example 1:
A basic pyramid chart with minimum mandatory input, and using system generated default options.
pyramid_chart population, over(agegrp) by(sex) dec(0)
Example 2:
Add titles to the graph, add 1 decimal place to the bar labels.
pyramid_chart population, over(agegrp) by(sex) dec(1) title("Population Pyramid for year 2000") subtitle("in percentages") xtitle("Percentage") ytitle("Age groups")
Example 3:
Add scatterplot options (for example, for color selection of bar labels).
pyramid_chart population, over(agegrp) by(sex) dec(1) title("Population Pyramid for year 2000") subtitle("in percentages") xtitle("Percentage") ytitle("Age groups") sctopt(mlabcolor(blue))
Example 4:
Add various schemes to the graph.
pyramid_chart population, over(agegrp) by(sex) dec(1) title("Population Pyramid for year 2000") subtitle("in percentages") xtitle("Percentage") ytitle("Age groups") sctopt(mlabcolor(blue)) scheme(white_tableau)
pyramid_chart population, over(agegrp) by(sex) dec(1) title("Population Pyramid for year 2000") xtitle("Percentage") ytitle("Age groups") scheme(economist)
Documentation
Detailed documentation for the pyramid_chart program is available in the pyramid_chart.sthlp file. You can access it in Stata using the help command:
help pyramid_chart
Version updates
v1.2: released on July 10th, 2024. Submitted to SSC for update.
- Bug fixed: color for bars/ bar labels can now be controlled by the user using regular
graph/scatter/twowayoptions. - Bug fixed: typos in
pyramid_chart.sthlpfile fixed. - Feature added: now can use scatter plot options
sctoptinside the syntax.
- Bug fixed: color for bars/ bar labels can now be controlled by the user using regular
v1.1: first release on July 07, 2024. Now the package is available from Stata terminal:
ssc install pyramid_chart.
Contributing
Contributions are welcome! If you find a bug or have a feature request, please open an issue on GitHub. If you'd like to contribute code, please fork the repository and submit a pull request.
- July 10, 2024: Fernando Rios-Avila added version check, added dynamic color selection to the left and right bars, and added the ability to use scatter options for coloring the bar labels.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Owner
- Name: Masud Rahman
- Login: masud90
- Kind: user
- Company: UNHCR
- Website: masud90.github.io
- Twitter: masudtweets
- Repositories: 2
- Profile: https://github.com/masud90
Economist. Data Scientist.
Citation (CITATION.cff)
@Misc{RePEc:boc:bocode:s459350,
author={Masud Rahman},
title={{PYRAMID_CHART: Stata module to generate a population pyramid chart}},
year=2024,
month=Jul,
howpublished={Statistical Software Components, Boston College Department of Economics},
abstract={pyramid_chart generates a population pyramid chart for a given numeric variable, with categories defined by two categorical variables. The chart displays the distribution of the numeric variable across the levels of the first categorical variable, split by the levels of the second categorical variable.},
keywords={population pyramid; Stata},
doi={},
url={https://ideas.repec.org/c/boc/bocode/s459350.html},
}
GitHub Events
Total
- Watch event: 1
- Push event: 1
Last Year
- Watch event: 1
- Push event: 1