*! version 2.3.1 22Feb2026

help unicefdataversion 2.3.1

Title

unicefdata -- Download indicators from UNICEF Data Warehouse

Syntax

unicefdata, Parameters [Options]

Parameters

indicator(code) indicator code(s) to download (accepts multiples)

(or)

dataflow(code) dataflow ID to download all indicators

Options

countries(codes) filter by ISO3 country codes

year(range) time period (single year, range, or list)

long keep data in long format (default)

wide reshape with years as columns (yr2018, yr2019, etc.)

wide_indicators reshape with indicators as columns

wide_attributes reshape with disaggregations as columns

latest keep only the most recent value per country-disaggregation

circa find closest available year

clear replace data in memory

sex(value) filter by sex (_T, M, F, or ALL)

wealth(value) filter by wealth quintile

residence(value) filter by urban/rural

addmeta(fields) add country metadata columns

simplify keep only essential columns

nosparse keep all standard columns (default: drop empty)

dropna drop missing values

subnational enable access to subnational dataflows

verbose display progress messages

fromfile(filename) load from CSV file instead of API (CI/testing)

tofile(filename) save API response to CSV for test fixtures

noerror suppress printed error messages (programmatic use)

clearcache drop all in-memory cached frames and exit

Metadata Sync

sync sync all metadata from UNICEF API

sync(target) sync specific metadata: all, dataflows, indicators, countries, codelists, regions

force bypass 30-day cache freshness check

forcepython use Python XML parser

forcestata use pure Stata XML parser

unicefdata requires an internet connection. See What's New for version history.

Sections

Syntax |
Defaults |
Options |
Examples |
Stored results |
Metadata |
Cross-Platform |
Author

Default Behavior

(Go up to Sections Menu)

Summary of defaults when options are omitted:

Option Default Value

countries() All countries

year() All available years

sex() Total only (_T)

wealth() Total only (_T)

residence() Total only (_T)

age() Total only (_T)

maternal_edu() Total only (_T)

Output format long (one row per observation)

Empty columns sparse (drop empty columns)

Missing values Keep missing values

Variable names All lowercase

Variable labels Descriptive labels on all variables

Key behavioral notes:

• Disaggregation defaults: All filter options (sex, wealth, residence,
age, maternal_edu) default to totals (_T) when omitted. Use ALL to
retrieve all available disaggregation values.

• Variable naming: All variable names are lowercase (e.g., indicator, not
INDICATOR). All variables have descriptive labels.

• Codes-only columns (default): API requests use labels=id to return
code values and avoid duplicate human-readable label columns. Output columns are
codes by default; map to labels via metadata as needed. This matches the default
behavior in the R and Python implementations.

• Wide format: When using wide, year columns are prefixed with yr
(e.g., yr2018, yr2019). Context variables (iso3, country, indicator, sex,
wealth_quintile, data_source, unit, geo_type) appear before year columns.

• Sparse mode: By default, columns with no data are dropped. Use nosparse
to keep all 22 standard columns for cross-platform consistency.

Options

(Go up to Sections Menu)

Main

indicator(string) specifies the indicator code(s) to download.
Multiple indicators can be separated by spaces. Use indicator(all) to
download all indicators from a dataflow in bulk download mode, which is
significantly faster than fetching indicators individually. Example indicators include:

CME_MRY0T4 - Under-5 mortality rate

CME_MRY0 - Infant mortality rate

NT_ANT_HAZ_NE2 - Stunting prevalence

IM_DTP3 - DTP3 immunization coverage

WS_PPL_W-B - Basic drinking water services

all - Download all indicators from specified dataflow (bulk mode)

dataflow(string) specifies the dataflow ID. When specified without indicator(),
automatically activates bulk download mode and downloads all indicators from the dataflow.
A warning message will be displayed. Use the verbose option to see progress.
Common dataflows include:

CME - Child mortality estimates

NUTRITION - Nutrition indicators

IMMUNISATION - Immunization coverage

EDUCATION - Education indicators

WASH_HOUSEHOLDS - Water, sanitation, and hygiene

HIV_AIDS - HIV/AIDS indicators

MNCH - Maternal, newborn, child health

ECD - Early childhood development

PT - Child protection

countries(string) filters data to specific countries using ISO3 codes.
Multiple codes can be space or comma separated (e.g., countries(ALB USA BRA)).

year(string) specifies the year(s) to retrieve. Supports three formats:

Single year: year(2020) - fetch only 2020

Range: year(2015:2023) - fetch years 2015 through 2023

List: year(2015,2018,2020) - fetch non-contiguous years

If omitted, all available years are retrieved.

circa finds the closest available year for each country when the exact
requested year is not available. This allows cross-country comparisons when
data availability varies. Different countries may have different actual years
in the result. Only applies when year() is specified.

Example: year(2015), circa might return 2014 data for Country A and
2016 data for Country B if 2015 is not available for either.

Constraint: circa requires year() to be specified. Using circa
without year() raises error 198.

Disaggregation Filters

sex(string) filters by sex. Values include:

_T - Total (both sexes, default)

F - Female

M - Male

ALL - Keep all disaggregations

age(string), wealth(string), residence(string), and
maternal_edu(string) provide additional disaggregation filters.

Default behavior: If you omit a disaggregation option, unicefdata defaults
to totals (_T) for sex, age, wealth, residence, and maternal_edu. Specify
ALL to keep all available categories instead of the total-only default.

Missing filter values: If you request a disaggregation value that is not present
in the data, unicefdata leaves the dataset unchanged. With verbose, a note
is shown indicating the requested value was not found.

Discovery Commands (v1.3.0)

flows lists all available UNICEF SDMX dataflows. Use detail for
extended information and verbose for metadata path. dataflows is
an alias for flows.

dataflow(string) (v1.5.1) displays the schema for a specific dataflow,
including its dimensions (REF_AREA, INDICATOR, SEX, etc.) and attributes
(DATA_SOURCE, OBS_STATUS, etc.). This helps understand the structure of
the data and which filter options are available.

search(string) searches for indicators by keyword. Searches both
indicator codes and names (case-insensitive). Use limit(#) to control
maximum results.

Tier Filters (v1.8.x)

Default behavior: Discovery commands (such as search and indicators)
only include Tier 1 indicators by default — those verified and downloadable.
Higher tiers require explicit opt-in.

showtier2 includes Tier 2 indicators (officially defined with no data).
These may list dataflows: ["nodata"] and will display a warning.

showtier3 includes Tier 3 indicators (legacy/undocumented). These return
metadata for discovery but are not recommended for production use; a warning is displayed.

showall includes Tiers 1–3 in results. Use with care.

showorphans displays orphan indicators (present in catalogs but not mapped
to current dataflows). Useful for taxonomy maintenance; not recommended for analysis.

showlegacy is an alias for showtier3.

Warnings: When non-default tiers are shown, unicefdata emits a note
indicating the tier and subcategory (if available) to highlight provenance and risk.

indicators(string) lists all indicators available in a specific dataflow.
For example, unicefdata, indicators(CME) shows all child mortality indicators.

info(string) displays detailed metadata for a specific indicator, including
its name, category (dataflow), description, URN, API query URL, and supported
disaggregations with their SDMX codes. This uses the dataflow schema files in
_dataflows/ to determine which filter options are valid for each indicator.

The info() output includes:

• Indicator code, name, and description

• Category and dataflow mappings

• URN (Uniform Resource Name) for SDMX identification

• API Query URL (clickable link to test in browser)

• Supported disaggregations with human-readable values AND SDMX codes

Example output:

SEX (with totals)

Values: Male, Female

Codes: M, F, _T (total)

Output Options

Output Format - Sparse vs Full Schema

By default, unicefdata drops columns that are entirely empty or missing (sparse mode).
This reduces clutter and returns only columns with actual data. The number of columns
varies by indicator based on available disaggregations.

nosparse keeps all 22 standard columns even if they are empty. This is useful for:

• Cross-platform consistency: Ensures identical column structure across Python, R, Stata

• Appending datasets: All indicators have the same columns for append

• Programmatic access: Predictable column names without checking existence

Standard column schema (22 columns, always present with nosparse):

indicator, indicator_name, iso3, country, geo_type, period, value, unit, unit_name,

sex, sex_name, age, wealth_quintile, wealth_quintile_name, residence,

maternal_edu_lvl, lower_bound, upper_bound, obs_status, obs_status_name, data_source, ref_period, country_notes

Use simplify to keep only essential columns (iso3, country, indicator,
period, value, lower_bound, upper_bound).

Understanding Output Formats:

unicefdata offers four output formats for different analytical needs. The default
is long, which is the most flexible. The three wide_* options reshape data
for specific cross-tabulation or pivot scenarios.

Output Formats

Cross-Platform

(Go up to Sections Menu)

Default parity across Stata, R, and Python:

• Codes-only schema: All implementations default to returning codes-only
columns (no duplicate label-expansion columns). Stata uses labels=id
in API requests; R and Python align with the same default.

• Lowercase naming: Standardized lowercase variable names are used in all
clients (e.g., indicator, period, value). Indicator-specific
dimension code columns are preserved as codes.

• Sparse vs. full schema: For consistent column counts across platforms,
use Stata's default sparse mode or nosparse to keep the full standard schema.
R/Python defaults similarly avoid empty columns.

This cross-platform behavior improves reproducibility and validation consistency.
The number of columns varies by indicator based on available disaggregations:

• CME_MRY0T4 (under-5 mortality): ~18-20 columns (no age/residence/maternal education data)

• NT_ANT_HAZ_NE2 (stunting): ~23 columns (includes wealth quintile data)

long keeps data in long format (one observation per country-year-indicator).
This is the default format from the SDMX API and the most flexible for data analysis.
All disaggregation variables (sex, age, wealth, residence, matedu) are present as
separate columns. Use this format when you need maximum flexibility.

wide reshapes data to wide format with years as columns, using yr prefix.
Uses SDMX API csv-ts format (years as columns in the API response).
Result structure:

Rows: iso3 x indicator x all disaggregation values (sex, wealth, age, residence, matedu)

Columns: yr2018, yr2019, yr2020, yr2021, etc. (years with "yr" prefix)

Use case: Time-series analysis, trend visualization

Note: Cannot combine with wide_indicators or wide_attributes (different reshape methods)

wide_attributes (v1.5.1) reshapes data to wide format with disaggregation
attributes as column suffixes. Use this when you want all disaggregation variations
as separate columns.

Result structure:

Rows: iso3 x country x period (time years)

Columns: indicator_T, indicator_M, indicator_F, indicator_Q1, etc.

Use case: Compare disaggregations side-by-side, wealth gap analysis, gender parity analysis

Example for sex: CME_MRY0T4_T (total), CME_MRY0T4_M (male), CME_MRY0T4_F (female)

Example for wealth: NT_ANT_HAZ_NE2_Q1 (poorest), ..., NT_ANT_HAZ_NE2_Q5 (richest)

Example for combined: CME_MRY0T4_M_Q1 (male in poorest quintile)

Use attributes() to filter which suffixes appear in output

wide_indicators (v1.3.0; enhanced v1.5.2) reshapes data so that different indicators
become separate columns. Use this for cross-indicator analysis.

Result structure:

Rows: iso3 x country x period (and optionally disaggregations if attributes=ALL)

Columns: CME_MRY0T4, IM_DTP3, NT_ANT_HAZ_NE2, etc. (indicators as columns)

Default behavior: Keeps only _T (total) for all disaggregations (backward compatible)

v1.5.2 improvement: Now creates empty numeric columns for all requested indicators,

even when some indicators have zero observations after filtering. This prevents reshape

failures and "variable not found" errors.

Use case: Compare multiple indicators side-by-side, correlation analysis, reliable batch processing

Constraint: Requires two or more indicators. An error is raised if only one
indicator is specified. Use wide format instead for single-indicator reshaping.

attributes(string) (v1.5.1) specifies which disaggregation attribute values
to keep when using wide_attributes or wide_indicators. This allows flexible
filtering of rows before reshaping.

Key Facts About attributes():

• Works with: wide_attributes and wide_indicators (not with long or wide)

• Constraint: Using attributes() without wide_attributes or wide_indicators raises error 198.

• Syntax: Accepts space-separated attribute codes, case-insensitive

• Default for wide_indicators: _T (total only) - backward compatible

• Default for wide_attributes: No default - if attributes() not specified, all values included

• Special keyword: ALL - keep all attribute combinations

• Filtering applied: BEFORE reshape operations, not after

Important Constraint: wide_attributes and wide_indicators cannot
be used together. This is because they represent different reshape strategies.
Attempting both simultaneously results in ERROR 198.

Common Patterns:

Pattern 1: Time-series analysis

wide option x years as columns for trend visualization

Pattern 2: Equity gap analysis (wealth, gender, geography)

wide_attributes attributes(_T _Q1 _Q5) - compare richest vs poorest

wide_attributes attributes(_T _M _F) - compare gender disparities

Pattern 3: Cross-indicator comparison

wide_indicators - multiple indicators as columns for one period

Pattern 4: Full disaggregation matrix

wide_indicators attributes(ALL) - all sex/age/wealth combinations

Supported Attribute Codes:

Sex (_T, _M, _F):

_T = Total (both sexes)

_M = Male

_F = Female

Wealth Quintiles (_T, _Q1, _Q2, _Q3, _Q4, _Q5):

_T = Total

_Q1 = Poorest quintile

_Q2 = Second quintile

_Q3 = Middle quintile

_Q4 = Fourth quintile

_Q5 = Richest quintile

Residence (_T, _U, _R):

_T = Total

_U = Urban

_R = Rural

Age (varies by indicator):

_T = Total

_0 through _18 = Age-specific codes (varies by indicator)

Maternal Education (_T, _NoEd, _Prim, _Sec, _High):

_T = Total

_NoEd = No education

_Prim = Primary education

_Sec = Secondary education

_High = Higher education

Special Keyword:

ALL = Keep all attribute combinations (no filtering)

attributes() Examples:

attributes(_T _M _F) - Keep total, male, and female; drop other sex categories

attributes(_Q1 _Q2 _Q3 _Q4 _Q5) - Keep all quintiles; drop total

attributes(_T _Q1 _Q2 _Q3 _Q4 _Q5) - Keep total and all quintiles

attributes(_U _R) - Keep urban and rural only; drop total

attributes(ALL) - No filtering; keep all disaggregation combinations

Important Notes:

1. attributes() filtering is applied before reshape, not after.

2. If you specify invalid attribute codes, they are silently ignored.

3. If no rows match the filter, all rows are kept (with a warning in verbose mode).

4. Case-insensitive: attributes(_T) = attributes(_t).

5. For wide_indicators, default (attributes() empty) = _T (totals only).

6. For wide_attributes, default (attributes() empty) = All values included.

addmeta(string) (v1.3.0) adds metadata columns to the output.
Available metadata includes:

region - UNICEF regional classification

income_group - World Bank income classification

continent - Geographic continent

Example: addmeta(region income_group)

dropna drops observations with missing values. Aligned with R/Python dropna parameter.

simplify keeps only essential columns: iso3, country, indicator,
period, value, lb, ub. Aligned with R/Python simplify parameter.

latest keeps only the most recent non-missing value for each unique combination of
country, indicator, and disaggregation dimensions (sex, wealth, residence, age, maternal_edu).
This means sex(ALL) latest correctly returns the latest value for each sex category.
Useful for cross-sectional analysis.

mrv(#) keeps the N most recent values for each unique combination of
country, indicator, and disaggregation dimensions.

raw returns raw SDMX data without variable renaming or standardization.

Technical

curl (v1.5.2, default) uses curl for HTTP requests with proper User-Agent identification.

Network handling improvements:

• Better SSL/TLS and HTTPS support across platforms

• Automatic proxy detection and handling

• Automatic retry logic for temporary network failures

• User-Agent header: "unicefdata/2.3.1 (Stata)"

• Automatic fallback to Stata's import delimited if curl is unavailable

If your Stata installation lacks curl support or you prefer Stata's default import method,
use nocurl to disable curl and use Stata's import delimited instead.

max_retries(#) specifies the number of retry attempts (default: 3).
(Aligned with R/Python syntax.)

fallback (v1.3.0) enables automatic fallback to alternative dataflows
when the primary dataflow returns no data or a 404 error. This is enabled by
default when specifying an indicator.

nofallback (v1.3.0) disables the automatic dataflow fallback mechanism.

subnational (v1.8.0) enables access to subnational dataflows such as
WASH_HOUSEHOLD_SUBNAT. By default, subnational dataflows are blocked because
they contain very large datasets that may take considerable time to download.
Use this option to explicitly enable access to these dataflows.

Example: unicefdata, indicator(WS_PPL_W-B) subnational clear

nometadata suppresses the automatic display of indicator metadata when
retrieving data. By default, unicefdata displays a brief summary of the
indicator (name, dataflow, supported disaggregations) when downloading data.
Use this option to skip the metadata display.

clear allows the command to replace existing data in memory.

verbose displays progress messages during data download.

Metadata Sync (v2.3.0)

sync synchronizes all local YAML metadata files from the UNICEF SDMX API.
This is equivalent to running unicefdata_sync, all.
Metadata files are stored alongside the package source in the _/ directory
and are used for discovery, dataflow detection, and filter validation.

sync(target) synchronizes a specific metadata type. Valid targets:

all - all metadata types (default)

dataflows - dataflow definitions (69-71 dataflows)

indicators - indicator catalog (733 indicators)

countries - country ISO3 codes (453 countries)

codelists - dimension codelists (age, wealth, residence, etc.)

regions - regional aggregate codes (111 regions)

force bypasses the 30-day cache freshness check. By default,
sync skips metadata that was updated within the last 30 days.
Use force to re-download regardless of cache age.

forcepython forces use of the Python XML parser. Python is faster
and handles large files without Stata macro length limits. Requires
Python 3.6+ in PATH.

forcestata forces use of the pure Stata XML parser. No Python
dependency, but may truncate very large metadata files (e.g., the full
indicator catalog).

Note: For advanced sync options (enrichdataflows, fallbacksequences,
path(), suffix(), history), use the standalone
unicefdata_sync command directly.

Offline/CI Testing (v2.2.0)

fromfile(filename) loads data from a local CSV file instead of querying the
UNICEF SDMX API. This option skips all network requests and reads the specified
file using import delimited. Designed for CI/CD pipelines and deterministic
testing where network access is unavailable or undesirable.

The file must be a CSV with the same column structure as the API response.
Use tofile() to generate fixture files from live API responses.

Example: unicefdata, indicator(CME_MRY0T4) fromfile("test_data.csv") clear

tofile(filename) saves the raw API response to a CSV file after download.
The data is still loaded into memory as usual. Use this to create test fixture
files for offline testing with fromfile().

Example: unicefdata, indicator(CME_MRY0T4) tofile("fixtures/cme_mry0t4.csv") clear

Programmatic Use

noerror suppresses all printed error messages and prevents non-zero exit
codes. When enabled, errors are captured in r(success), r(successcode),
and r(fail_message) instead of being displayed. This allows callers to
handle errors programmatically without interrupting batch execution.

Use case: Looping over multiple indicators where some may not exist:

foreach ind in CME_MRY0T4 INVALID_IND IM_DTP3 {

capture noisily unicefdata, indicator(`ind') noerror clear

if r(success) == 1 save "`ind'.dta", replace

}

Cache Management

clearcache drops all in-memory cached frames (indicator-to-dataflow mappings
and parsed YAML data) and exits. The next unicefdata call will re-parse
metadata from YAML files. Use this after updating metadata files via
unicefdata_sync or when troubleshooting stale data.

Example: unicefdata, clearcache

Examples

(Go up to Sections Menu)

Discovery Commands (v1.3.0)

List available dataflows:

. unicefdata, flows

List dataflows with names:

. unicefdata, flows detail

Show dataflow schema (dimensions and attributes):

. unicefdata, dataflow(EDUCATION)

Show CME dataflow schema:

. unicefdata, dataflow(CME)

Search for mortality-related indicators:

. unicefdata, search(mortality)

Search within a specific dataflow:

. unicefdata, search(rate) dataflow(CME)

List indicators in the CME (Child Mortality Estimates) dataflow:

. unicefdata, indicators(CME)

Get detailed info about an indicator:

. unicefdata, info(CME_MRY0T4)

Data Retrieval

Download under-5 mortality rate for all countries:

. unicefdata, indicator(CME_MRY0T4) clear

Download for specific countries:

. unicefdata, indicator(CME_MRY0T4) countries(ALB USA BRA) clear

Download with year range:

. unicefdata, indicator(CME_MRY0T4) year(2010:2023) clear

Download specific years (non-contiguous):

. unicefdata, indicator(CME_MRY0T4) year(2015,2018,2020) clear

Get latest value per country:

. unicefdata, indicator(CME_MRY0T4) latest clear

Get female-only data:

. unicefdata, indicator(CME_MRY0T4) sex(F) clear

Bulk Download (All Indicators from Dataflow)

Explicit syntax - Use indicator(all) with dataflow():

. unicefdata, indicator(all) dataflow(CME) clear verbose

Implicit syntax - Specify dataflow() without indicator() (displays warning):

. unicefdata, dataflow(CME) countries(ETH) clear verbose

Bulk download with year filter:

. unicefdata, indicator(all) dataflow(NUTRITION) year(2020) clear

Bulk download with dimension filters (sex=female):

. unicefdata, indicator(all) dataflow(CME) sex(F) clear

Performance note: Bulk download is 5-10x faster than fetching indicators individually.
Use verbose option to monitor progress for large downloads.

Additional Data Retrieval Options

Get 5 most recent values per country:

. unicefdata, indicator(CME_MRY0T4) mrv(5) clear

Simplify output to essential columns:

. unicefdata, indicator(CME_MRY0T4) simplify dropna clear

Reshape Options (v1.5.1): wide, wide_attributes, wide_indicators with attributes()

Understanding the Three Reshape Options:

1. wide - Pivots years as columns (standard time-series format):

Rows: iso3 × indicator × disaggregation attributes (sex, age, wealth, etc.)

Columns: yr2018, yr2019, yr2020, yr2021 (years as columns with "yr" prefix)

Use: When you want time-series analysis with years as columns

2. wide_attributes - Pivots disaggregation suffixes (e.g., sex, wealth):

Rows: iso3 × country × period (time)

Columns: indicator_T, indicator_M, indicator_F (for sex disaggregation)

Use: When you want all attribute variations as separate columns

Example: CME_MRY0T4_T (total), CME_MRY0T4_M (male), CME_MRY0T4_F (female)

3. wide_indicators - Pivots indicators as columns (cross-indicator analysis):

Rows: iso3 × country × period × (optionally disaggregations if attributes=ALL)

Columns: CME_MRY0T4, IM_DTP3, NT_ANT_HAZ_NE2 (indicators as columns)

Use: When you want to compare multiple indicators side-by-side

Default: Keeps only _T (total) for all disaggregations (backward compatible)

Important: wide_attributes and wide_indicators cannot be used together.
Choose one reshape option. The attributes() option applies filtering before
reshape and works with both options.

Supported Attribute Codes for attributes() Option:

Sex disaggregation:

_T - Total (both sexes)

_M - Male

_F - Female

Wealth quintile:

_T - Total

_Q1 - Poorest quintile

_Q2 - Second quintile

_Q3 - Middle quintile

_Q4 - Fourth quintile

_Q5 - Richest quintile

Residence:

_T - Total

_U - Urban

_R - Rural

Special keyword:

ALL - Keep all attribute combinations

Reshape Examples - wide, wide_attributes, wide_indicators

Quick single-command examples:

wide - Years as columns:

. unicefdata, indicator(CME_MRY0T4) countries(USA BRA) year(2018:2021) wide clear

wide_attributes - Disaggregations as column suffixes:

. unicefdata, indicator(CME_MRY0T4) countries(USA BRA) year(2020) sex(ALL) wide_attributes clear

wide_indicators - Indicators as columns:

. unicefdata, indicator(CME_MRY0T4 IM_DTP3) countries(USA BRA CHN) year(2020) wide_indicators clear

attributes() - Filter specific disaggregations (requires NUTRITION dataflow):

. unicefdata, indicator(NT_ANT_HAZ_NE2) dataflow(NUTRITION) countries(ETH KEN) wealth(ALL) wide_attributes attributes(_Q1 _Q5) clear

Note: wide_attributes and wide_indicators cannot be used together.

v1.3.0-v1.5.0 Features

Add regional and income group metadata:

. unicefdata, indicator(CME_MRY0T4) addmeta(region income_group) clear

Circa matching (find closest year):

. unicefdata, indicator(CME_MRY0T4) year(2020) circa clear

Nutrition Indicators

Stunting prevalence:

. unicefdata, indicator(NT_ANT_HAZ_NE2) clear

Stunting by wealth quintile (Q1=poorest) - requires NUTRITION dataflow:

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

Stunting by residence (rural only) - requires NUTRITION dataflow:

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

Immunization Indicators

DTP3 immunization coverage:

. unicefdata, indicator(IM_DTP3) clear

Measles immunization coverage:

. unicefdata, indicator(IM_MCV1) clear

WASH Indicators

Basic drinking water services:

. unicefdata, indicator(WS_PPL_W-B) clear

Basic sanitation services:

. unicefdata, indicator(WS_PPL_S-B) clear

Education Indicators

Out-of-school rate, primary:

. unicefdata, indicator(ED_ROFST_L1) clear

Net attendance rate, primary:

. unicefdata, indicator(ED_ANAR_L1) clear

Export Examples

Download and export to Excel:

. unicefdata, indicator(CME_MRY0T4) countries(ALB USA BRA) clear

. export excel using "mortality_data.xlsx", firstrow(variables) replace

Download and export to CSV:

. unicefdata, indicator(CME_MRY0T4) countries(ALB USA BRA) clear

. export delimited using "mortality_data.csv", replace

Advanced Examples

Under-5 mortality trend analysis for South Asian countries:

. unicefdata, indicator(CME_MRY0T4) countries(AFG BGD BTN IND MDV NPL PAK LKA) clear
. keep if sex == "_T"
. graph twoway ///
(connected value period if iso3 == "AFG", lcolor(red)) ///
(connected value period if iso3 == "BGD", lcolor(blue)) ///
(connected value period if iso3 == "IND", lcolor(green)) ///
(connected value period if iso3 == "PAK", lcolor(orange)), ///
legend(order(1 "Afghanistan" 2 "Bangladesh" 3 "India" 4 "Pakistan")) ///
ytitle("Under-5 mortality rate") title("U5MR Trends in South Asia")
(click to run)

Stunting prevalence by wealth quintile:

. unicefdata, indicator(NT_ANT_HAZ_NE2) sex(ALL) latest clear
. keep if inlist(wealth_quintile, "Q1", "Q2", "Q3", "Q4", "Q5")
. gen wealth_num = real(substr(wealth_quintile, 2, 1))
. collapse (mean) mean_stunting = value, by(wealth_quintile wealth_num)
. graph bar mean_stunting, over(wealth_quintile) ///
ytitle("Stunting prevalence (%)") ///
title("Child Stunting by Wealth Quintile")
(click to run)

Multiple mortality indicators comparison for Latin America:

. unicefdata, indicator(CME_MRY0T4 CME_MRY0 CME_MRM0) ///
countries(BRA MEX ARG COL PER CHL) year(2020:2023) clear
. keep if sex == "_T"
. bysort iso3 indicator (period): keep if _n == _N
. keep iso3 country indicator value
. reshape wide value, i(iso3 country) j(indicator) string
. graph bar valueCME_MRY0T4 valueCME_MRY0 valueCME_MRM0, ///
over(country, label(angle(45))) ///
legend(order(1 "Under-5" 2 "Infant" 3 "Neonatal"))
(click to run)

Global immunization coverage trends:

. unicefdata, indicator(IM_DTP3 IM_MCV1) year(2000:2023) clear
. * Note: IMMUNISATION dataflow does not have sex disaggregation
. collapse (mean) coverage = value, by(period indicator)
. reshape wide coverage, i(period) j(indicator) string
. graph twoway ///
(line coverageIM_DTP3 period, lcolor(blue)) ///
(line coverageIM_MCV1 period, lcolor(red)), ///
legend(order(1 "DTP3" 2 "MCV1")) ///
title("Global Immunization Coverage Trends")
(click to run)

Regional comparison with metadata:

. unicefdata, indicator(CME_MRY0T4) addmeta(region income_group) latest clear
. keep if geo_type == 0 & sex == "_T" // geo_type 0 = country
. collapse (mean) avg_u5mr = value, by(region)
. gsort -avg_u5mr
. graph hbar avg_u5mr, over(region, sort(1) descending) ///
ytitle("Under-5 mortality rate") ///
title("U5MR by UNICEF Region")
(click to run)

Export comprehensive data to Excel:

. unicefdata, indicator(CME_MRY0T4) countries(ALB USA BRA IND CHN NGA) ///
year(2015:2023) addmeta(region income_group) clear
. keep iso3 country region income_group period value lower_bound upper_bound
. export excel using "unicef_mortality_data.xlsx", firstrow(variables) replace
(click to run)

WASH urban-rural gap analysis:

. unicefdata, indicator(WS_PPL_W-B) residence(ALL) latest clear
. keep if inlist(residence, "U", "R")
. replace residence = "Urban" if residence == "U"
. replace residence = "Rural" if residence == "R"
. bysort iso3 : egen n_res = nvals(residence)
. keep if n_res == 2
. reshape wide value, i(iso3 country) j(residence) string
. gen gap = valueUrban - valueRural
. gsort -gap
. list iso3 country valueUrban valueRural gap in 1/10
(click to run)

Using wide option - Time series format:

. unicefdata, indicator(CME_MRY0T4) countries(USA BRA IND CHN) ///
year(2015:2023) wide clear
. keep if sex == "_T"
. list iso3 country yr2015 yr2020 yr2023, sep(0) noobs
. gen change_2015_2023 = yr2023 - yr2015
. gen pct_change = (change_2015_2023 / yr2015) * 100
(click to run)

Using wide_indicators - Multiple indicators as columns (v1.5.2):

. unicefdata, indicator(CME_MRY0T4 CME_MRY0 IM_DTP3 IM_MCV1) ///
countries(AFG ETH PAK NGA) latest wide_indicators clear
. keep if sex == "_T"
. describe CME_MRY0T4 CME_MRY0 IM_DTP3 IM_MCV1
. list iso3 country CME_MRY0T4 CME_MRY0 IM_DTP3 IM_MCV1, sep(0) noobs
. correlate CME_MRY0T4 IM_DTP3
(click to run)

Using wide_attributes - Disaggregations as columns (v1.5.1):

. unicefdata, indicator(CME_MRY0T4) countries(IND PAK BGD) ///
year(2020) sex(ALL) wide_attributes clear
. list iso3 country CME_MRY0T4_T CME_MRY0T4_M CME_MRY0T4_F, sep(0) noobs
. gen mf_gap = CME_MRY0T4_M - CME_MRY0T4_F
(click to run)

Using attributes() filter - Targeted disaggregation (requires NUTRITION dataflow):

. unicefdata, indicator(NT_ANT_HAZ_NE2) dataflow(NUTRITION) countries(IND PAK BGD ETH) ///
latest attributes(_T _Q1 _Q5) wide_attributes clear
. list iso3 country NT_ANT_HAZ_NE2_T NT_ANT_HAZ_NE2_Q1 NT_ANT_HAZ_NE2_Q5, ///
sep(0) noobs
. gen wealth_gap = NT_ANT_HAZ_NE2_Q1 - NT_ANT_HAZ_NE2_Q5
(click to run)

Metadata Sync

Sync all metadata from UNICEF API:

. unicefdata, sync verbose

Sync indicators only:

. unicefdata, sync(indicators) verbose

Force refresh all metadata (bypass 30-day cache):

. unicefdata, sync force verbose

Force refresh dataflows only:

. unicefdata, sync(dataflows) force verbose

For advanced options, use the standalone command (unicefdata_sync):

. unicefdata_sync, all enrichdataflows fallbacksequences verbose

Stored results

(Go up to Sections Menu)

unicefdata stores the following in r():

Scalars

r(obs_count) number of observations downloaded

r(success) 1 if data was retrieved, 0 on failure

r(successcode) numeric error code (0 = success, 677 = not found, etc.)

Macros

r(indicator) indicator code(s) requested

r(dataflow) dataflow ID used

r(countries) countries requested (if specified)

r(start_year) start year (if specified)

r(end_year) end year (if specified)

r(wide) wide format indicator

r(wide_indicators) wide_indicators format indicator (v1.3.0)

r(addmeta) metadata columns added (v1.3.0)

r(url) API URL used for download

r(fail_message) error description when r(success)==0

r(tried_dataflows) comma-separated list of dataflows attempted (on 404)

Indicator Metadata (single indicator only)

r(indicator_name) full indicator name

r(indicator_category) indicator category

r(indicator_dataflow) dataflow containing this indicator

r(indicator_description) indicator description

r(indicator_urn) SDMX URN identifier

r(has_sex) 1 if sex disaggregation supported

r(has_age) 1 if age disaggregation supported

r(has_wealth) 1 if wealth quintile supported

r(has_residence) 1 if urban/rural supported

r(has_maternal_edu) 1 if maternal education supported

r(supported_dims) list of supported dimensions (e.g., "sex wealth")

Discovery commands store additional results:

flows

r(n_dataflows) number of dataflows found

r(dataflow_ids) list of dataflow IDs

search

r(n_matches) number of matching indicators

r(indicators) list of matching indicator codes

r(keyword) search keyword used

indicators

r(n_indicators) number of indicators in dataflow

r(indicators) list of indicator codes

r(dataflow) dataflow queried

info

r(indicator) indicator code

r(name) indicator name

r(category) category (usually same as dataflow)

r(dataflow) dataflow ID for this indicator

r(description) indicator description

r(has_sex) 1 if sex disaggregation supported

r(has_age) 1 if age disaggregation supported

r(has_wealth) 1 if wealth quintile supported

r(has_residence) 1 if urban/rural supported

r(has_maternal_edu) 1 if maternal education supported

r(supported_dims) list of supported dimensions

YAML Metadata

(Go up to Sections Menu)

unicefdata uses two types of YAML metadata for discovery and validation,
aligned with the R get_unicef() and Python unicef_api implementations.

Indicator Metadata

Indicator-level metadata provides information about each of the 733 indicators:

_unicefdata_indicators_metadata.yaml - Full indicator catalog

Contains: code, name, description, URN, category, dataflow

Use case: info(indicator), search(keyword), dataflow auto-detection

Dataflow Metadata

Dataflow-level metadata provides information about each of the 69 dataflows:

_unicefdata_dataflows.yaml - Dataflow summary (name, agency, version)

Use case: flows listing, dataflow descriptions

_dataflows/*.yaml - Per-dataflow schema files (69 files)

Contains: dimensions (SEX, AGE, WEALTH_QUINTILE, RESIDENCE, etc.)

Use case: info(indicator) disaggregation support, filter validation

Reference Metadata

Reference metadata for valid codes and country/region lists:

_unicefdata_codelists.yaml - Valid codes for sex, age, wealth, residence

_unicefdata_countries.yaml - 453 country ISO3 codes

_unicefdata_regions.yaml - 111 regional aggregate codes

The yaml command is used to parse these files. If yaml is not installed,
the command falls back to prefix-based dataflow detection.

To synchronize metadata from the UNICEF SDMX API:

. unicefdata_sync, verbose

To install the yaml package:

. ssc install yaml

Cross-Platform Consistency

(Go up to Sections Menu)

All three platforms (Python, R, Stata) generate identical metadata files with:

- Same record counts (69 dataflows, 453 countries, etc.)

- Same field names and structures

- Standardized _metadata headers with platform, version, timestamp

- Shared indicator definitions from config/common_indicators.yaml

Use the Python status script to verify consistency:

python tests/generate_metadata_status.py --detailed

Author

(Go up to Sections Menu)

Joao Pedro Azevedo

UNICEF

jpazevedo@unicef.org

https://jpazvd.github.io/

This command is part of the unicefData package, which provides
R, Python, and Stata interfaces to the UNICEF Data Warehouse.

For more information, see https://github.com/unicef-drp/unicefData

Also see

Online: UNICEF Data Warehouse,
UNICEF SDMX API

Help: unicefdata_sync, get_sdmx, and unicefdata_examples. Also see wbopendata for a similar command for World Bank data.