*! version 2.7.0 2026-04-04

Title

wdi_deflate -- Convert monetary values across PPP,
USD, and LCU using WDI deflators

Syntax

Build deflator dataset from WDI

wdi_deflate build
, saving(filename) [replace gdp
countries(codelist) snapshot(dirname)]

Convert monetary variables

wdi_deflate varlist [if] [in]
, country(varname) from(#|varname) to(#)
[using(filename) gdp usd deflate
fromppp fromusd
suffix(string) replace quiet]

Describe a deflator dataset

wdi_deflate describe
, using(filename)

build options

* saving(filename) path to save the deflator .dta
file

replace overwrite existing file

gdp use GDP PPP factor (PA.NUS.PPP) instead of private
consumption (PA.NUS.PRVT.PP)

countries(codelist) space-separated ISO3 codes to
download (e.g. countries(ETH TZA USA)); if omitted, downloads
all countries

snapshot(dirname) save individual WDI indicator files
(ppp_factor.dta, cpi.dta, xr.dta) to dirname for archival

convert options

* country(varname) string variable containing ISO
3166-1 alpha-3 country codes (e.g. ETH, TZA, SOM)

* from(#|varname) source year of input values; an
integer for fixed year or a numeric variable for panel data

* to(#) target reference year (e.g. 2017)

using(filename) path to deflator dataset built by
wdi_deflate build; if omitted, downloads current WDI data
automatically

gdp use GDP PPP factor (PA.NUS.PPP) instead of private
consumption; only relevant when using() is omitted

usd convert to nominal US dollars instead of PPP
international dollars

deflate deflate to constant LCU (CPI adjustment only, no
spatial conversion)

fromppp input values are already in PPP international
dollars (year from()). With default mode, rebases to PPP$ in
year to(). With deflate, converts to constant LCU

fromusd input values are already in nominal USD
(year from()). With usd, rebases to USD in year to().
With deflate, converts to constant LCU

suffix(string) suffix for new variables; defaults are
_pppYYYY, _usdYYYY, or _realYYYY

replace replace varlist in place instead of generating
new variables

quiet suppress diagnostic output

* required

Description

wdi_deflate converts monetary variables between local currency
units (LCU), PPP international dollars, and nominal US dollars,
adjusting for inflation using World Development Indicators (WDI) data.
It creates new variables (or replaces existing ones) containing the
converted values. The command handles both cross-sectional data with a
fixed source year and panel data where the source year varies by
observation.

By default, wdi_deflate downloads current WDI data automatically,
so a single command is all you need. For replicability, use
wdi_deflate build to save a deflator snapshot and pass it via
using(). Seven conversion paths are available:

LCU -> PPP (default): applies temporal deflation (CPI) and spatial
conversion (PPP factor).

LCU -> USD (usd): applies temporal deflation (CPI) and
converts at the official exchange rate.

LCU -> constant LCU (deflate): applies CPI deflation only.

PPP -> PPP (fromppp): rebases PPP international dollars from
one ICP round to another. Reverses through LCU, applies CPI, then
reconverts.

USD -> USD (usd fromusd): rebases nominal USD from one
year to another. Reverses through LCU, applies CPI, then reconverts.

PPP -> LCU (fromppp deflate): converts PPP
international dollars back to local currency, then deflates to constant
LCU.

USD -> LCU (fromusd deflate): converts nominal USD
back to local currency using the exchange rate, then deflates to
constant LCU.

One-step (default): wdi_deflate varlist downloads current
WDI data automatically and performs the conversion in a single command.

Two-step (for replicability): wdi_deflate build downloads
three WDI indicators via wbopendata — the PPP conversion factor
(PA.NUS.PRVT.PP or PA.NUS.PPP), the consumer price index (FP.CPI.TOTL),
and the official exchange rate (PA.NUS.FCRF) — and saves them as a
snapshot. Then wdi_deflate varlist, using(filename)
uses that snapshot for conversion, ensuring exact reproducibility even
if WDI data are later revised.

Formulas

LCU -> PPP (default)

PPP$_y = LCU x (CPI_y / CPI_x) / PPP_y

LCU -> USD

USD_y = LCU x (CPI_y / CPI_x) / XR_y

LCU -> constant LCU

LCU' = LCU x (CPI_y / CPI_x)

PPP -> PPP (fromppp)

PPP$_y = PPP$_x x PPP_x x (CPI_y / CPI_x) / PPP_y

USD -> USD (fromusd)

USD_y = USD_x x XR_x x (CPI_y / CPI_x) / XR_y

PPP -> LCU (fromppp deflate)

LCU_y = PPP$_x x PPP_x x (CPI_y / CPI_x)

USD -> LCU (fromusd deflate)

LCU_y = USD_x x XR_x x (CPI_y / CPI_x)

where x is the source year (from()) and y is the target
year (to()), CPI is the WDI consumer price index (FP.CPI.TOTL,
base 2010=100), PPP is the conversion factor in LCU per international
dollar, and XR is the official exchange rate in LCU per US dollar
(PA.NUS.FCRF, period average). The fromppp and fromusd
paths multiply by the source-year factor to recover LCU before applying
the standard conversion.

Examples

LCU -> 2021 PPP $ (one-step, auto-downloads WDI data)

. clear

. set obs 2

. gen iso3 = cond(_n==1, "ETH", "TZA")

. gen year = cond(_n==1, 2018, 2019)

. gen consumption = cond(_n==1, 15000, 850000)

. gen income = cond(_n==1, 22000, 1200000)

. wdi_deflate consumption income, country(iso3) from(year) to(2021)

. list

* Creates: consumption_ppp2021, income_ppp2021

Two-step workflow for replicability

. wdi_deflate build, saving(deflator.dta) countries(ETH TZA) replace

. clear

. set obs 2

. gen iso3 = cond(_n==1, "ETH", "TZA")

. gen year = cond(_n==1, 2018, 2019)

. gen consumption = cond(_n==1, 15000, 850000)

. wdi_deflate consumption, country(iso3) from(year) to(2021) using(deflator.dta)

. list

The remaining examples assume a dataset with the referenced variables
is already in memory.

LCU -> nominal USD

wdi_deflate consumption, country(iso3) from(year) to(2021) usd

* Creates: consumption_usd2021

Deflate to constant LCU

wdi_deflate consumption, country(iso3) from(year) to(2021) deflate

* Creates: consumption_real2021

Build deflator for specific countries only (faster)

wdi_deflate build, saving(deflator.dta) countries(ETH TZA USA) replace

Rebase 2011 PPP $ to 2017 PPP $

wdi_deflate cost_ppp consumption,
country(iso3) from(2011) to(2017)
using(deflator.dta) fromppp

* Creates: cost_ppp_ppp2017, consumption_ppp2017

Rebase 2015 USD to 2020 USD

wdi_deflate cost_usd,
country(iso3) from(2015) to(2020)
using(deflator.dta) usd fromusd

* Creates: cost_usd_usd2020

PPP international dollars -> constant LCU

wdi_deflate consumption_ppp,
country(iso3) from(2017) to(2020)
using(deflator.dta) fromppp deflate

* Creates: consumption_ppp_real2020

Nominal USD -> constant LCU

wdi_deflate cost_usd,
country(iso3) from(2020) to(2022)
using(deflator.dta) fromusd deflate

* Creates: cost_usd_real2022

Panel data with variable source year

wdi_deflate income,
country(iso3) from(year) to(2017)
using(deflator.dta) suffix(_ppp17)

Replace in place

wdi_deflate consumption,
country(countrycode) from(2011) to(2017)
using(deflator.dta) fromppp replace

Convert only rural observations

wdi_deflate consumption if urban==0,
country(iso3) from(year) to(2017)
using(deflator.dta)

Notes

Country codes: country() must contain ISO 3166-1 alpha-3 codes
(e.g. ETH, TZA, SOM). Convert with kountry if needed
(ssc install kountry).

Exchange rate caveat: The usd option uses the WDI official
exchange rate (PA.NUS.FCRF, period average). For countries with parallel
or black-market rates, this may diverge substantially from market rates.

PPP rebasing: fromppp is useful for rebasing values expressed
in PPP dollars from one ICP round to another — for example, harmonizing
cost-effectiveness thresholds or program cost benchmarks across studies
that use different PPP vintages.

Applying international poverty lines to survey data: To apply a
PPP-denominated threshold (e.g. $2.15/day in 2017 PPP) to household
survey data in local currency, combine fromppp with deflate
to convert the line to constant LCU for each country. Note that the
World Bank's international poverty lines ($1.90, $2.15, $3.00) are
independently derived as the median of national poverty lines at each
ICP round — they are not mechanical CPI/PPP rebases of one another.
Use fromppp for rebasing your own PPP$ values across ICP rounds,
not for replicating the Bank's poverty line updates.

Missing values: Observations whose country-year is not found in WDI
will have missing converted values. The diagnostic output reports the
count of such cases.

CPI base year: The WDI CPI uses 2010 = 100, but since the formula
uses a CPI ratio, the base year cancels out.

Replicability: The deflator .dta file is a snapshot of WDI data at
the time build was run. Archive it alongside your do-file for
exact reproducibility, since re-running build may pull revised WDI
data (e.g., after CPI rebasing or currency reforms). The
snapshot() option saves the raw indicator files (ppp_factor.dta,
cpi.dta, xr.dta) separately for archival. The convert output displays
the deflator build date and data signature so you can verify which
vintage was used.

Country filtering: The countries() option on build
limits the download to specified countries, which is much faster than a
full-world download. When using() is omitted, the auto-download
path automatically extracts unique country codes from your data and
downloads only those countries. If you later merge the deflator with
data containing countries not in the original download, the diagnostic
output will identify which missing countries need to be added.

Dependencies: wdi_deflate build and auto-download require
wbopendata (ssc install wbopendata) and tknz
(ssc install tknz). When using() is specified, the
convert step has no dependencies beyond the saved .dta file.

WDI indicators used

PA.NUS.PRVT.PP — PPP conversion factor, private consumption (LCU per intl $)

PA.NUS.PPP — PPP conversion factor, GDP (LCU per intl $) [gdp option]

FP.CPI.TOTL — Consumer price index (2010 = 100)

PA.NUS.FCRF — Official exchange rate (LCU per US$, period average)

Stored results

wdi_deflate stores the following in r():

Scalars

r(N) number of observations in scope

r(miss_src) observations missing source-year CPI

r(miss_tgt) observations missing target-year divisor

r(to) target year

Macros

r(mode) conversion mode (ppp, usd, or
deflate)

r(newvars) names of created or modified variables

References

Azevedo, J.P. (2011) "wbopendata: Stata module to access World Bank
databases," Statistical Software Components S457234, Boston College
Department of Economics.
http://ideas.repec.org/c/boc/bocode/s457234.html

Author

Kalle Hirvonen, International Food Policy Research Institute (IFPRI).
k.hirvonen@cgiar.org

Last updated

4 April 2026