*! version 1.7.1 01Feb2026

unicefdata_examples — Gallery of unicefdata usage examples

Syntax

unicefdata_examples example_name [, verbose]

example_name Name of example to run: example01 through example11

verbose Enable step-by-step debugging output

Interactive Multi-Step Examples

These examples demonstrate complete analytical workflows. Run them with verbose
to see each step executed:

. unicefdata_examples example02, verbose

Available Examples

example01 — Under-5 mortality trend analysis for South Asia

Downloads CME_MRY0T4, filters to totals, creates trend graph for 4 countries.

example02 — Stunting by wealth quintile

Uses nofilter to get all data, filters to Q1-Q5, creates bar chart.

example03 — Multiple mortality indicators comparison

Downloads 3 CME indicators for Latin America, reshapes wide, creates grouped bar chart.

example04 — Immunization coverage trends

Downloads DTP3 and MCV1, calculates global averages, creates trend graph.

example05 — Regional comparison with metadata

Uses addmeta(region) option, aggregates by UNICEF region, creates horizontal bar chart.

example06 — Export to Excel

Downloads data with metadata, selects columns, exports to Excel file.

example07 — WASH urban-rural gap analysis

Uses residence(ALL), calculates urban-rural gap, lists top 10 countries.

example08 — Wide format time series

Uses wide option to create yr#### columns, calculates percent change.

example09 — Multiple indicators as columns

Uses wide_indicators option to create indicator columns, calculates correlations.

example10 — Sex disaggregation analysis

Uses sex(ALL), reshapes to wide, calculates male-female mortality gap.

example11 — Wealth equity gap analysis

Uses wealth(ALL), reshapes to wide, calculates Q1-Q5 stunting gap.

Verbose Option

The verbose option shows detailed debugging information:

• Each command before execution

• Data state after each step (observations, variables)

• Key variable values (wealth_quintile, sex, residence)

Use verbose mode to understand workflows or debug issues:

. unicefdata_examples example02, verbose

Quick Examples

Example 1: Simple single-indicator download

. unicefdata, indicator(CME_MRY0T4) clear

Downloads under-5 mortality rate for all countries and years available.

Example 2: Multiple indicators

. unicefdata, indicator(CME_MRY0T4 CME_MRY0 CME_MRM0) countries(IND PAK BGD) clear

Fetches three mortality indicators (under-5, infant, neonatal) for three countries.

Example 3: No default filters (get ALL data)

. unicefdata, indicator(NT_ANT_HAZ_NE2) nofilter clear

Downloads all disaggregations without any default filters. Filter in Stata afterward.

Example 4: Wide format for easy analysis

. unicefdata, indicator(CME_MRY0T4 CME_MRY0) wide_indicators clear

Reshapes to wide format with separate columns for each indicator.

Example 5: Disaggregated data with filters

. unicefdata, indicator(NT_ANT_HAZ_NE2) wealth(Q1) clear

Downloads stunting data filtered to poorest quintile (Q1).

Example 6: Latest available data only

. unicefdata, indicator(IM_DTP3) latest clear

Fetches only the most recent DTP3 immunization data for each country.

Example 7: Detailed progress output

. unicefdata, indicator(CME_MRY0T4) verbose clear

Shows all API calls and detailed metadata.

Cookbook

Task: Compare mortality across countries

. unicefdata, indicator(CME_MRY0T4) countries(SWE USA ZAF) clear

. keep if sex == "_T"

. twoway line value period, by(country)

Task: Wealth equity analysis

. unicefdata, indicator(NT_ANT_HAZ_NE2) nofilter clear

. keep if period > 2020

. keep if inlist(wealth_quintile, "Q1", "Q5")

. collapse (mean) stunting = value, by(wealth_quintile)

Task: Search for available indicators

. unicefdata, search(stunting)

Task: Create a merge-ready dataset

. unicefdata, indicator(CME_MRY0T4) latest clear

. keep iso3 period value

. save mortality_data.dta, replace

. merge 1:1 iso3 using mydata.dta

Task: Specify dataflow explicitly

. unicefdata, indicator(NT_ANT_HAZ_NE2) dataflow(NUTRITION) clear

Bypass auto-detection for known dataflow (faster for batch operations).

Tips and Tricks

Filtering

• Use nofilter to download all disaggregations, then filter in Stata

• Use wealth(ALL), sex(ALL), residence(ALL) for specific dimensions

• Use latest option to get only the most recent data point per country

Discovery

• Use unicefdata, flows to list available dataflows

• Use unicefdata, search(keyword) to find indicators

• Use unicefdata, info(indicator_code) to see metadata

Debugging

• Use verbose during development to see API calls

• Use unicefdata_examples example##, verbose to trace multi-step workflows

Common Issues

Q: "No observations returned"

A: Check indicator code and country codes (use ISO3). Use verbose to see API URL.

Q: "Disaggregation not supported" warning

A: Not all indicators support all disaggregations. Use unicefdata, info(indicator) to see available filters.

Q: "Variable not found" error

A: Variable names depend on the dataflow. Use describe after download to see actual column names.

Q: Default filters removing data I need

A: Use nofilter option to download all data, then filter manually in Stata.

Author

Joao Pedro Azevedo, UNICEF

https://jpazvd.github.io

}

See also

unicefdata (main command)

get_sdmx (low-level fetching)

unicefdata_sync (metadata synchronization)