---
title: "WID Codes Dictionary"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{WID Codes Dictionary}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(collapse = TRUE, comment = "#>", eval = FALSE)
library(widr)
```

This vignette mirrors the official [WID Codes Dictionary](https://wid.world/codes-dictionary/) section by section, with `widr` function calls woven in wherever a function applies. For methodology and estimation, see the [DINA Guidelines](https://wid.world/document/distributional-national-accounts-dina-guidelines-2025-methods-and-concepts-used-in-the-world-inequality-database/).

---

## 1. General Presentation

`widr` provides direct R access to the WID API. The primary interface is `download_wid()`, which returns a `wid_df` -- a classed `data.frame` compatible with dplyr, ggplot2, and base R.

```{r download-sig}
download_wid(
  indicators             = "all",
  areas                  = "all",
  years                  = "all",
  perc                   = "all",
  ages                   = "992",   # default: adults 20+
  pop                    = "j",     # default: equal-split
  metadata               = FALSE,
  include_extrapolations = TRUE,
  verbose                = FALSE,
  cache                  = TRUE)
```

`metadata = TRUE` attaches source documentation as `attr(result, "wid_meta")`. Cache responses are managed with `wid_cache()`, `wid_cache_list()`, and `wid_cache_clear()`. Set an API key with `wid_set_key()`.

---

## 2. General Structure

Every series has a WID code (concept), a percentile code, a country/region code, and a year. Codes are built by combining series type, concept, age group, and population unit.

### 2.1 WID Code Examples

The three canonical examples from the official dictionary:

| Type | Concept | Age | Pop | Percentile | Country | Year | Meaning |
|------|---------|-----|-----|-----------|---------|------|---------|
| `s` | `ptinc` | `992` | `j` | `p99p100` | `US` | `1970` | share of pretax national income, top 1%, equal-split adults, United States |
| `l` | `pfghg` | `999` | `i` | `p90p100` | `CH` | `2014` | avg. per capita group emissions, personal carbon footprint, top 10%, Switzerland |
| `s` | `pllin` | `992` | `f` | `p0p100` | `UY` | `2023` | share of pretax labour income, female, entire adult population, Uruguay |

```{r decode-encode}
wid_decode("sptinc992j")
#> $series_type  "s"     $concept  "ptinc"     $age  "992"     $pop  "j"

wid_encode("s", "ptinc", "992", "j")       #> [1] "sptinc992j"
wid_encode("m", "nninc")                   #> [1] "mnninc"
wid_encode(wid_decode("sptinc992j"))       # round-trip: identical to input

# Validate (throws on failure) or check silently
wid_validate(series_type = "s", concept = "ptinc", age = 992, pop = "j")
wid_is_valid(series_type = "s", concept = "ptinc")   #> [1] TRUE
wid_is_valid(series_type = "Z")                       #> [1] FALSE
```

### 2.1.1 Series Type (one-letter code)

There are `r nrow(wid_series_types)` types.

```{r series-types}
wid_series_types
wid_search("share", tables = "series_types")
```

| Code | Meaning | Unit |
|------|---------|------|
| `a` | average | local currency, last year's prices |
| `b` | inverted Pareto-Lorenz coefficient | no unit |
| `e` | total emissions | tonnes CO2-equivalent |
| `f` | female population | fraction (0 to 1) |
| `g` | Gini coefficient | 0 to 1 |
| `i` | index | no unit |
| `k` | per capita emissions | tonnes CO2-equivalent |
| `l` | average per capita group emissions | tonnes CO2-equivalent |
| `m` | total | local currency, last year's prices |
| `n` | population | people |
| `p` | proportion of women | fraction (0 to 1) |
| `r` | top 10 / bottom 50 ratio | no unit |
| `s` | share | fraction (0 to 1) |
| `t` | threshold | local currency, last year's prices |
| `w` | wealth-to-income ratio or labor/capital share | fraction of national income |
| `x` | exchange rate (market or PPP) | local currency per foreign currency |
| `y` | wealth-to-GDP ratio | fraction of GDP |

All monetary amounts are in local currency at constant prices. For world regions: `XX-MER` (USD MER) or `XX-PPP` (USD PPP). Shares and ratios are fractions: a top-1% share of 20% = `0.2`; a 300% wealth/income ratio = `3`. Series types `s`, `g`, `b`, `w`, `r`, `p`, `i`, `y` are dimensionless; `wid_convert()` passes them through unchanged.

### 2.1.2 Concept (five-letter code)

Characters 2-6 (or 2-7 for six-letter concepts). There are `r nrow(wid_concepts)` concepts.

```{r concepts}
nrow(wid_concepts)
head(wid_concepts)
wid_search("wealth")
wid_search("^ptinc$", tables = "concepts")
wid_search("wealth", type = "s")
wid_search("income", tables = "all")
```

### 2.1.3 Age Group (three-digit code)

There are `r nrow(wid_ages)` defined age groups. `anninc999i` = national income per capita; `anninc992i` = national income per adult.

```{r ages}
wid_ages
wid_validate(age = 992)
```

| Code | Population |
|------|-----------|
| `999` | All ages |
| `992` | Adults 20+ *(default)* |
| `996` | Working-age, 20-64 |
| `995` | Adults 60+ |
| `994` | Adults 40-59 |
| `993` | Adults 20-39 |
| `997` | Elderly 65+ |
| `998` | Aged 80+ |
| `991` | Below 20 |
| `014` | Ages 0-14 |
| `156` | Ages 15-64 |
| `001` | Ages 0-4 |
| `051` | Ages 5-9 |
| `101` | Ages 10-14 |
| `151` | Ages 15-19 |
| `201` | Ages 20-24 |
| `251` | Ages 25-29 |
| `301` | Ages 30-34 |
| `351` | Ages 35-39 |
| `401` | Ages 40-44 |
| `451` | Ages 45-49 |
| `501` | Ages 50-54 |
| `551` | Ages 55-59 |
| `601` | Ages 60-64 |
| `651` | Ages 65-69 |
| `701` | Ages 70-74 |
| `751` | Ages 75-79 |
| `801` | Ages 80-84 |
| `851` | Ages 85-89 |
| `901` | Ages 90-94 |
| `951` | Ages 95-99 |
| `111` | Ages 99+ |
| `202` | Ages 20-29 |
| `302` | Ages 30-39 |
| `402` | Ages 40-49 |
| `502` | Ages 50-59 |
| `602` | Ages 60-69 |
| `702` | Ages 70-79 |
| `802` | Ages 80-89 |
| `902` | Ages 90-99 |

### 2.1.4 Population Unit (one-letter code)

There are `r nrow(wid_pop_types)` population unit codes. Only affects distributional series; aggregate series default to `i`.

```{r pop-types}
wid_pop_types
```

| Code | Description |
|------|------------|
| `i` | individuals |
| `j` | equal-split adults *(default)* |
| `m` | male |
| `f` | female |
| `t` | tax unit |
| `e` | employed |

### 2.1.5 Series Type x Population Unit Availability

```{r is-valid}
wid_is_valid(series_type = "s", concept = "ptinc")   # TRUE
wid_is_valid(series_type = "b", pop = "f")            # FALSE
```

| Series type | `f: female` | `i: individuals` | `j: equal-split adults` | `m: male` | `t: tax unit` |
|-------------|:---:|:---:|:---:|:---:|:---:|
| `a` average | + | + | + | + | + |
| `b` Pareto coef. | | + | + | | |
| `f` female pop. | | + | | | |
| `i` index | | + | | | |
| `m` total | | + | | | + |
| `n` population | + | + | | + | + |
| `p` prop. women | | + | | | |
| `s` share | + | + | + | + | + |
| `t` threshold | + | + | + | + | + |
| `w` wealth/income ratio | | + | | | + |
| `y` wealth-to-GDP ratio | | + | | | + |
| `x` exchange rate | | + | | | |
| `e`/`k`/`l` emissions | | + | | | |

---

## 2.2 Country Codes

There are `r nrow(wid_countries)` entries in `wid_countries`.

```{r countries}
head(wid_countries)
wid_search("^US", tables = "countries")
wid_validate(areas = c("US", "FR", "US-CA"))
```

### Country Codes

| WID code | Country | World region | Sub-division | Historical series | Sub-division of historical |
|----------|---------|-------------|-------------|------------------|---------------------------|
| AD | Andorra | Europe | | Other Western Europe | |
| AE | United Arab Emirates | MENA | | Main Country | |
| AF | Afghanistan | South & Southeast Asia | | Other South & Southeast Asia | |
| AG | Antigua and Barbuda | Latin America | | Other Latin America | |
| AI | Anguilla | Latin America | | Other Latin America | |
| AL | Albania | Europe | | Eastern Europe | |
| AM | Armenia | Russia & Central Asia | | Other Russia & Central Asia | |
| AO | Angola | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| AR | Argentina | Latin America | | Main Country | |
| AT | Austria | Europe | | Other Western Europe | |
| AU | Australia | North America & Oceania | Oceania | Main Country | |
| AW | Aruba | Latin America | | Other Latin America | |
| AZ | Azerbaijan | Russia & Central Asia | | Other Russia & Central Asia | |
| BA | Bosnia and Herzegovina | Europe | | Eastern Europe | |
| BB | Barbados | Latin America | | Other Latin America | |
| BD | Bangladesh | South & Southeast Asia | | Main Country | |
| BE | Belgium | Europe | | Other Western Europe | |
| BF | Burkina Faso | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| BG | Bulgaria | Europe | | Eastern Europe | |
| BH | Bahrain | MENA | | Other MENA | |
| BI | Burundi | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| BJ | Benin | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| BM | Bermuda | North America & Oceania | North America | Other North America & Oceania | Other North America |
| BN | Brunei Darussalam | South & Southeast Asia | | Other South & Southeast Asia | |
| BO | Bolivia | Latin America | | Other Latin America | |
| BQ | Bonaire | Latin America | | Other Latin America | |
| BR | Brazil | Latin America | | Main Country | |
| BS | Bahamas | Latin America | | Other Latin America | |
| BT | Bhutan | South & Southeast Asia | | Other South & Southeast Asia | |
| BW | Botswana | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| BY | Belarus | Russia & Central Asia | | Other Russia & Central Asia | |
| BZ | Belize | Latin America | | Other Latin America | |
| CA | Canada | North America & Oceania | North America | Main Country | |
| CD | DR Congo | Sub-Saharan Africa | | Main Country | |
| CF | Central African Republic | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| CG | Congo | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| CH | Switzerland | Europe | | Other Western Europe | |
| CI | Cote d'Ivoire | Sub-Saharan Africa | | Main Country | |
| CL | Chile | Latin America | | Main Country | |
| CM | Cameroon | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| CN | China | East Asia | | Main Country | |
| CO | Colombia | Latin America | | Main Country | |
| CR | Costa Rica | Latin America | | Other Latin America | |
| CU | Cuba | Latin America | | Other Latin America | |
| CV | Cabo Verde | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| CW | Curacao | Latin America | | Other Latin America | |
| CY | Cyprus | Europe | | Eastern Europe | |
| CZ | Czechia | Europe | | Eastern Europe | |
| DE | Germany | Europe | | Main Country | |
| DJ | Djibouti | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| DK | Denmark | Europe | | Main Country | |
| DM | Dominica | Latin America | | Other Latin America | |
| DO | Dominican Republic | Latin America | | Other Latin America | |
| DZ | Algeria | MENA | | Main Country | |
| EC | Ecuador | Latin America | | Other Latin America | |
| EE | Estonia | Europe | | Eastern Europe | |
| EG | Egypt | MENA | | Main Country | |
| ER | Eritrea | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| ES | Spain | Europe | | Main Country | |
| ET | Ethiopia | Sub-Saharan Africa | | Main Country | |
| FI | Finland | Europe | | Other Western Europe | |
| FJ | Fiji | North America & Oceania | Oceania | Other North America & Oceania | Other Oceania |
| FM | Micronesia | North America & Oceania | Oceania | Other North America & Oceania | Other Oceania |
| FR | France | Europe | | Main Country | |
| GA | Gabon | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| GB | United Kingdom | Europe | | Main Country | |
| GD | Grenada | Latin America | | Other Latin America | |
| GE | Georgia | Russia & Central Asia | | Other Russia & Central Asia | |
| GG | Guernsey | Europe | | Other Western Europe | |
| GH | Ghana | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| GI | Gibraltar | Europe | | Other Western Europe | |
| GL | Greenland | North America & Oceania | North America | Other North America & Oceania | Other North America |
| GM | Gambia | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| GN | Guinea | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| GQ | Equatorial Guinea | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| GR | Greece | Europe | | Other Western Europe | |
| GT | Guatemala | Latin America | | Other Latin America | |
| GW | Guinea-Bissau | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| GY | Guyana | Latin America | | Other Latin America | |
| HK | Hong Kong | East Asia | | Other East Asia | |
| HN | Honduras | Latin America | | Other Latin America | |
| HR | Croatia | Europe | | Eastern Europe | |
| HT | Haiti | Latin America | | Other Latin America | |
| HU | Hungary | Europe | | Eastern Europe | |
| ID | Indonesia | South & Southeast Asia | | Main Country | |
| IE | Ireland | Europe | | Other Western Europe | |
| IL | Israel | MENA | | Other MENA | |
| IM | Isle of Man | Europe | | Other Western Europe | |
| IN | India | South & Southeast Asia | | Main Country | |
| IQ | Iraq | MENA | | Other MENA | |
| IR | Iran | MENA | | Main Country | |
| IS | Iceland | Europe | | Other Western Europe | |
| IT | Italy | Europe | | Main Country | |
| JE | Jersey | Europe | | Other Western Europe | |
| JM | Jamaica | Latin America | | Other Latin America | |
| JO | Jordan | MENA | | Other MENA | |
| JP | Japan | East Asia | | Main Country | |
| KE | Kenya | Sub-Saharan Africa | | Main Country | |
| KG | Kyrgyzstan | Russia & Central Asia | | Other Russia & Central Asia | |
| KH | Cambodia | South & Southeast Asia | | Other South & Southeast Asia | |
| KI | Kiribati | North America & Oceania | Oceania | Other North America & Oceania | Other Oceania |
| KM | Comoros | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| KN | Saint Kitts and Nevis | Latin America | | Other Latin America | |
| KP | North Korea | East Asia | | Other East Asia | |
| KR | South Korea | East Asia | | Main Country | |
| KS | Kosovo | Europe | | Eastern Europe | |
| KW | Kuwait | MENA | | Other MENA | |
| KY | Cayman Islands | Latin America | | Other Latin America | |
| KZ | Kazakhstan | Russia & Central Asia | | Other Russia & Central Asia | |
| LA | Lao PDR | South & Southeast Asia | | Other South & Southeast Asia | |
| LB | Lebanon | MENA | | Other MENA | |
| LC | Saint Lucia | Latin America | | Other Latin America | |
| LI | Liechtenstein | Europe | | Other Western Europe | |
| LK | Sri Lanka | South & Southeast Asia | | Other South & Southeast Asia | |
| LR | Liberia | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| LS | Lesotho | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| LT | Lithuania | Europe | | Eastern Europe | |
| LU | Luxembourg | Europe | | Other Western Europe | |
| LV | Latvia | Europe | | Eastern Europe | |
| LY | Libya | MENA | | Other MENA | |
| MA | Morocco | MENA | | Main Country | |
| MC | Monaco | Europe | | Other Western Europe | |
| MD | Moldova | Europe | | Eastern Europe | |
| ME | Montenegro | Europe | | Eastern Europe | |
| MG | Madagascar | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| MH | Marshall Islands | North America & Oceania | Oceania | Other North America & Oceania | Other Oceania |
| MK | North Macedonia | Europe | | Eastern Europe | |
| ML | Mali | Sub-Saharan Africa | | Main Country | |
| MM | Myanmar | South & Southeast Asia | | Main Country | |
| MN | Mongolia | East Asia | | Other East Asia | |
| MO | Macao | East Asia | | Other East Asia | |
| MR | Mauritania | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| MS | Montserrat | Latin America | | Other Latin America | |
| MT | Malta | Europe | | Other Western Europe | |
| MU | Mauritius | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| MV | Maldives | South & Southeast Asia | | Other South & Southeast Asia | |
| MW | Malawi | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| MX | Mexico | Latin America | | Main Country | |
| MY | Malaysia | South & Southeast Asia | | Other South & Southeast Asia | |
| MZ | Mozambique | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| NA | Namibia | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| NC | New Caledonia | North America & Oceania | Oceania | Other North America & Oceania | Other Oceania |
| NE | Niger | Sub-Saharan Africa | | Main Country | |
| NG | Nigeria | Sub-Saharan Africa | | Main Country | |
| NI | Nicaragua | Latin America | | Other Latin America | |
| NL | Netherlands | Europe | | Main Country | |
| NO | Norway | Europe | | Main Country | |
| NP | Nepal | South & Southeast Asia | | Other South & Southeast Asia | |
| NR | Nauru | North America & Oceania | Oceania | Other North America & Oceania | Other Oceania |
| NZ | New Zealand | North America & Oceania | Oceania | Main Country | |
| OM | Oman | MENA | | Other MENA | |
| PA | Panama | Latin America | | Other Latin America | |
| PE | Peru | Latin America | | Other Latin America | |
| PF | French Polynesia | North America & Oceania | Oceania | Other North America & Oceania | Other Oceania |
| PG | Papua New Guinea | North America & Oceania | Oceania | Other North America & Oceania | Other Oceania |
| PH | Philippines | South & Southeast Asia | | Main Country | |
| PK | Pakistan | South & Southeast Asia | | Main Country | |
| PL | Poland | Europe | | Eastern Europe | |
| PR | Puerto Rico | Latin America | | Other Latin America | |
| PS | Palestine | MENA | | Other MENA | |
| PT | Portugal | Europe | | Other Western Europe | |
| PW | Palau | North America & Oceania | Oceania | Other North America & Oceania | Other Oceania |
| PY | Paraguay | Latin America | | Other Latin America | |
| QA | Qatar | MENA | | Other MENA | |
| RO | Romania | Europe | | Eastern Europe | |
| RS | Serbia | Europe | | Eastern Europe | |
| RU | Russia | Russia & Central Asia | | Main Country | |
| RW | Rwanda | Sub-Saharan Africa | | Main Country | |
| SA | Saudi Arabia | MENA | | Main Country | |
| SB | Solomon Islands | North America & Oceania | Oceania | Other North America & Oceania | Other Oceania |
| SC | Seychelles | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| SD | Sudan | Sub-Saharan Africa | | Main Country | |
| SE | Sweden | Europe | | Main Country | |
| SG | Singapore | South & Southeast Asia | | Other South & Southeast Asia | |
| SI | Slovenia | Europe | | Eastern Europe | |
| SK | Slovakia | Europe | | Eastern Europe | |
| SL | Sierra Leone | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| SM | San Marino | Europe | | Other Western Europe | |
| SN | Senegal | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| SO | Somalia | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| SR | Suriname | Latin America | | Other Latin America | |
| SS | South Sudan | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| ST | Sao Tome and Principe | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| SV | El Salvador | Latin America | | Other Latin America | |
| SX | Sint Maarten (Dutch part) | Latin America | | Other Latin America | |
| SY | Syria | MENA | | Other MENA | |
| SZ | Eswatini | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| TC | Turks and Caicos Islands | Latin America | | Other Latin America | |
| TD | Chad | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| TG | Togo | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| TH | Thailand | South & Southeast Asia | | Main Country | |
| TJ | Tajikistan | Russia & Central Asia | | Other Russia & Central Asia | |
| TL | Timor-Leste | South & Southeast Asia | | Other South & Southeast Asia | |
| TM | Turkmenistan | Russia & Central Asia | | Other Russia & Central Asia | |
| TN | Tunisia | MENA | | Other MENA | |
| TO | Tonga | North America & Oceania | Oceania | Other North America & Oceania | Other Oceania |
| TR | Turkiye | MENA | | Main Country | |
| TT | Trinidad and Tobago | Latin America | | Other Latin America | |
| TV | Tuvalu | North America & Oceania | Oceania | Other North America & Oceania | Other Oceania |
| TW | Taiwan | East Asia | | Main Country | |
| TZ | Tanzania | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| UA | Ukraine | Russia & Central Asia | | Other Russia & Central Asia | |
| UG | Uganda | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| US | USA | North America & Oceania | North America | Main Country | |
| UY | Uruguay | Latin America | | Other Latin America | |
| UZ | Uzbekistan | Russia & Central Asia | | Other Russia & Central Asia | |
| VC | Saint Vincent and the Grenadines | Latin America | | Other Latin America | |
| VE | Venezuela | Latin America | | Other Latin America | |
| VG | Virgin Islands, British | Latin America | | Other Latin America | |
| VN | Viet Nam | South & Southeast Asia | | Main Country | |
| VU | Vanuatu | North America & Oceania | Oceania | Other North America & Oceania | Other Oceania |
| WS | Samoa | North America & Oceania | Oceania | Other North America & Oceania | Other Oceania |
| YE | Yemen | MENA | | Other MENA | |
| ZA | South Africa | Sub-Saharan Africa | | Main Country | |
| ZM | Zambia | Sub-Saharan Africa | | Other Sub-Saharan Africa | |
| ZW | Zimbabwe | Sub-Saharan Africa | | Other Sub-Saharan Africa | |

### World Region Codes

Regions available in two currency variants. The decomposition `(=) WO = (+) QE + (+) QL + (+) XB + (+) XF + (+) XL + (+) XN + (+) XR + (+) XS`.

| PPP code | MER code | Region |
|----------|----------|--------|
| WO-PPP | WO-MER | World |
| QE-PPP | QE-MER | Europe |
| OC-PPP | OC-MER | Other Western Europe |
| QM-PPP | QM-MER | Eastern Europe |
| QL-PPP | QL-MER | East Asia |
| OB-PPP | OB-MER | Other East Asia |
| XB-PPP | XB-MER | North America and Oceania |
| QF-PPP | QF-MER | Oceania |
| OL-PPP | OL-MER | Other Oceania |
| QP-PPP | QP-MER | North America |
| OK-PPP | OK-MER | Other North America |
| OH-PPP | OH-MER | Other North America and Oceania |
| XF-PPP | XF-MER | Sub-Saharan Africa |
| OJ-PPP | OJ-MER | Other Sub-Saharan Africa |
| XL-PPP | XL-MER | Latin America |
| OD-PPP | OD-MER | Other Latin America |
| XN-PPP | XN-MER | MENA (Middle East and North Africa) |
| OE-PPP | OE-MER | Other MENA |
| XR-PPP | XR-MER | Russia and Central Asia |
| OA-PPP | OA-MER | Other Russia and Central Asia |
| XS-PPP | XS-MER | South and Southeast Asia |
| OI-PPP | OI-MER | Other South and Southeast Asia |

### Historical Country Codes

| WID code | Country |
|----------|---------|
| CS | Czechoslovakia |
| DD | German Democratic Republic |
| SU | USSR |
| YU | Yugoslavia |
| ZZ | Zanzibar |

### Country Subregion Codes

| WID code | Region |
|----------|--------|
| CN-RU | Rural China |
| CN-UR | Urban China |
| DE-BD | Baden |
| DE-BY | Bavaria |
| DE-HB | Bremen |
| DE-HE | Hesse |
| DE-HH | Hamburg |
| DE-PR | Prussia |
| DE-SN | Saxony |
| DE-WU | Wurttemberg |
| US-AK | Alaska |
| US-AL | Alabama |
| US-AR | Arkansas |
| US-AZ | Arizona |
| US-CA | California |
| US-CO | Colorado |
| US-CT | Connecticut |
| US-DC | District of Columbia |
| US-DE | Delaware |
| US-FL | Florida |
| US-GA | Georgia |
| US-HI | Hawaii |
| US-IA | Iowa |
| US-ID | Idaho |
| US-IL | Illinois |
| US-IN | Indiana |
| US-KS | Kansas |
| US-KY | Kentucky |
| US-LA | Louisiana |
| US-MA | Massachusetts |
| US-MD | Maryland |
| US-ME | Maine |
| US-MI | Michigan |
| US-MN | Minnesota |
| US-MO | Missouri |
| US-MS | Mississippi |
| US-MT | Montana |
| US-NC | North Carolina |
| US-ND | North Dakota |
| US-NE | Nebraska |
| US-NH | New Hampshire |
| US-NJ | New Jersey |
| US-NM | New Mexico |
| US-NV | Nevada |
| US-NY | New York |
| US-OH | Ohio |
| US-OK | Oklahoma |
| US-OR | Oregon |
| US-PA | Pennsylvania |
| US-RI | Rhode Island |
| US-SC | South Carolina |
| US-SD | South Dakota |
| US-TN | Tennessee |
| US-TX | Texas |
| US-UT | Utah |
| US-VA | Virginia |
| US-VT | Vermont |
| US-WA | Washington |
| US-WI | Wisconsin |
| US-WV | West Virginia |
| US-WY | Wyoming |

---

## 2.3 Percentile Codes

There are `r nrow(wid_percentiles)` enumerated codes of the form `pXpY` (X < Y, both 0-100).

```{r percentiles}
head(wid_percentiles)
wid_search("top 1", tables = "percentiles")
wid_validate(perc = "p99p100")
wid_validate(perc = "p90p10")    # error: invalid order
```

**Key groups** (most widely used): `p0p100`, `p0p50`, `p50p90`, `p90p100`, `p99p100`, `p99.9p100`, `p99.99p100`, and all deciles `p0p10`, `p10p20`, ..., `p90p100`.

**Detailed percentile groups:** all centiles (`p0p1` through `p99p100`), tenths within the top 1% (`p99.1p99.2`, ..., `p99.9p100`), hundredths within the top 0.1%, and thousandths within the top 0.01%.

**Detailed top groups:** population above a given percentile -- `p1p100`, `p2p100`, ...

**Detailed bottom groups:** population below a given percentile -- `p0p99`, `p0p98`, ...

For each group, WID provides: **share** (`s`), **average** (`a`), **threshold** (`t`), and for top groups the **inverted Pareto-Lorenz coefficient** (`b`) -- the ratio of group average to group threshold, measuring fatness of the distributional tail.

Note: individuals are not always ranked by the quantity being measured. Use `wid_decode()` or `wid_metadata()` to confirm the ranking variable.

---

## 3. Aggregate Income Variables

### 3.1.1 GDP and Net National Income

```{r nni}
download_wid(indicators = "anninc992i", areas = "FR", years = 1900:2023)
```

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `nninc` | (=) net national income | B5n | S1 |
| `ndpro` | (+) net domestic product | | |
| `gdpro` | (+) gross domestic product | B1g | S14+S15 |
| `confc` | (-) consumption of fixed capital | P51c | S1 |
| `nnfin` | (+) foreign income | (-) B5n | S2 |

### 3.1.2 Decomposition of Foreign Income

**Paid/Received**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `nnfin` | (=) net foreign income | | |
| `finrx` | (+) foreign income received from the rest of the world | | |
| `flcir` | (+) labor and capital income from the rest of the world | D1+D4 | S2 |
| `comrx` | (+) compensation of employees received | D1 | S2 |
| `pinrx` | (+) property income received | D4 | S2 |
| `fdirx` | (+) foreign direct investment income | | |
| `ptfrx` | (+) portfolio and other income | | |
| `ptdrx` | (+) debt income | | |
| `pterx` | (+) equity income | | |
| `ptrrx` | (+) reserves income | | |
| `ptfrr` | (+) reinvested earnings on foreign portfolio investment | | |
| `fsubx` | (+) subsidies on prod. received from rest of world | D3 | S2 |
| `fpsub` | (+) subsidies on products | D31 | S2 |
| `fosub` | (+) other subsidies on production | D39 | S2 |
| `finpx` | (-) foreign income paid to the rest of the world | | |
| `flcip` | (+) labor and capital income paid to rest of world | | |
| `compx` | (+) compensation of employees paid | D1 | S2 |
| `pinpx` | (+) property income paid | D4 | S2 |
| `fdipx` | (+) foreign direct investment income paid | | |
| `ptfpx` | (+) portfolio and other income paid | | |
| `ptdpx` | (+) debt income paid | | |
| `ptepx` | (+) equity income paid | | |
| `ptfrp` | (+) reinvested earnings on foreign portfolio investment paid | | |
| `ftaxx` | (+) taxes on prod. paid to rest of world | D2 | S2 |
| `fptax` | (+) taxes on products | D21 | S2 |
| `fotax` | (+) other taxes on production | D29 | S2 |

**Labor/Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `nnfin` | (=) net foreign income | | |
| `flcin` | (+) net foreign labor and capital income | | |
| `pinnx` | (+) net foreign capital income | D4 | S2 |
| `fdinx` | (+) net foreign direct investment income | | |
| `ptfnx` | (+) net portfolio income | | |
| `ptdnx` | (+) net debt income | | |
| `ptenx` | (+) net equity income | | |
| `ptfrn` | (+) net reinvested earnings on foreign portfolio investment | | |
| `ptrrx` | (+) reserves income | | |
| `comnx` | (+) net foreign labor income | D1 | S2 |
| `taxnx` | (+) subsidies less taxes on production and imports | D3-D2 | S2 |
| `prtxn` | (+) subsidies less taxes on products | D31-D21 | S2 |
| `optxn` | (+) other subsidies less taxes on production | D39-D29 | S2 |

### 3.1.3 Decomposition of Foreign Wealth

| WID code | Description |
|----------|-------------|
| `nwnxa` | (=) net foreign assets |
| `fdixn` | (+) net foreign direct investment |
| `fdixa` | (+) foreign direct investment assets |
| `fdixd` | (-) foreign direct investment liabilities |
| `ptfxn` | (+) net foreign portfolio |
| `ptfxa` | (+) portfolio assets |
| `ptexa` | (+) portfolio equity assets |
| `ptdxa` | (+) portfolio debt assets |
| `ptrxa` | (+) foreign reserve exchange assets |
| `ptfxd` | (-) portfolio liabilities |
| `ptexd` | (+) portfolio equity liabilities |
| `ptdxd` | (+) portfolio debt liabilities |

### 3.1.4 Decomposition of National Income between Sectors

**Primary Income Decomposition**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `nninc` | (=) net national income | B5n | S1 |
| `prigo` | (+) net primary income of the general government | B5n | S13 |
| `prihn` | (+) net primary income of households and non-profits | B5n | S14+S15 |
| `priho` | (+) net primary income of households | B5n | S14 |
| `prinp` | (+) net primary income of non-profits | B5n | S15 |
| `prico` | (+) net primary income of corporations | B5n | S11+S12 |
| `prinf` | (+) net primary income of non-financial corporations | B5n | S11 |
| `prifc` | (+) net primary income of financial corporations | B5n | S12 |

**Secondary Income Decomposition**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `nninc` | (=) net national income | B5n | S1 |
| `secgo` | (+) net secondary income of the general government | B6n+D7 | S13 |
| `sechn` | (+) net secondary income of households and non-profits | B6n+D7 | S14+S15 |
| `secho` | (+) net secondary income of households | B6n+D7 | S14 |
| `secnp` | (+) net secondary income of non-profits | B6n+D7 | S15 |
| `secco` | (+) net secondary income of corporations | B6n+D7 | S11+S12 |
| `secnf` | (+) net secondary income of non-financial corporations | B6n+D7 | S11 |
| `secfc` | (+) net secondary income of financial corporations | B6n+D7 | S12 |

**Decomposition of Property Income between Sectors**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `pinnx` | (=) net foreign property income | (-) D4 | S2 |
| `prphn` | (+) property income of households and NPISH | D4 | S14+S15 |
| `prpco` | (+) property income of corporations | D4 | S11+S12 |
| `prpgo` | (+) property income of the government | D4 | S13 |

**Decomposition of Direct Taxes on Income and Wealth between Sectors**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `taxgo` | (=) direct taxes received by the government | D5 | S13 |
| `tiwhn` | (+) taxes on income and wealth paid by households | D5 | S14+S15 |
| `taxco` | (+) corporate tax | D5 | S11+S12 |

**Decomposition of Social Security Contributions between Sectors**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `sschn` | (=) social contributions paid by households and NPISH | D61 | S14+S15 |
| `sscgo` | (+) social contributions received by the government | D61 | S13 |
| `sscco` | (+) social contributions to private employer social insurance | D61 | S11+S12 |

**Decomposition of Social Security Benefits between Sectors**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `ssbhn` | (=) social benefits received by households and NPISH | D61 | S14+S15 |
| `ssbgo` | (+) social benefits paid by the government | D61 | S13 |
| `ssbco` | (+) social benefits from private employer social insurance | D61 | S11+S12 |

**Decomposition of Net Savings between Sectors**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `savin` | (=) net savings of the total economy | B8n+D7 | S1 |
| `savhn` | (+) net savings of households and NPISH | B8n+D7 | S14+S15 |
| `savho` | (+) net savings of households | B8n+D7 | S14 |
| `savnp` | (+) net savings of NPISH | B8n+D7 | S15 |
| `savco` | (+) net savings/secondary income of corporations | B8n+D7 | S11+S12 |
| `secnf` | (+) net savings of non-financial corporations | B8n+D7 | S11 |
| `secfc` | (+) net savings of financial corporations | B8n+D7 | S12 |
| `savgo` | (+) net savings of the general government | B8n+D7 | S13 |

**Decomposition of Gross Savings between Sectors**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `savig` | (=) gross savings of the total economy | B8g+D7 | S1 |
| `saghn` | (+) gross savings of households and NPISH | B8g+D7 | S14+S15 |
| `sagho` | (+) gross savings of households | B8g+D7 | S14 |
| `sagnp` | (+) gross savings of NPISH | B8g+D7 | S15 |
| `sagco` | (+) gross savings/secondary income of corporations | B8g+D7 | S11+S12 |
| `segnf` | (+) gross savings of non-financial corporations | B8g+D7 | S11 |
| `segfc` | (+) gross savings of financial corporations | B8g+D7 | S12 |
| `saggo` | (+) gross savings of the general government | B8g+D7 | S13 |

**Net and Gross Variables across Sectors**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `confc` | (=) consumption of fixed capital of the total economy | P51c | S1 |
| `cfchn` | (+) CFC of households and NPISH | P51c | S14+S15 |
| `cfcho` | (+) CFC of households | P51c | S14 |
| `cfcnp` | (+) CFC of NPISH | P51c | S15 |
| `cfcco` | (+) CFC of corporations | P51c | S11+S12 |
| `cfcnf` | (+) CFC of non-financial corporations | P51c | S11 |
| `cfcfc` | (+) CFC of financial corporations | P51c | S12 |
| `cfcgo` | (+) CFC of the general government | P51c | S13 |
| `savin` | (=) net savings of the total economy | B8n+D7 | S1 |
| `savig` | (+) gross savings of the total economy | B8g+D7 | S1 |
| `confc` | (-) consumption of fixed capital of the total economy | P51c | S1 |

### 3.1.5 Labor and Capital Share of National Income

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `nninc` | (=) net national income | B5n | S1 |
| `comhn` | (+) compensation of employees | D1 | S14+S15 |
| `fkpin` | (+) net capital income | | |
| `prphn` | (+) property income distributed to households and NPISH | D4 | S14+S15 |
| `prpgo` | (+) property income distributed to the government | D4 | S13 |
| `nsrhn` | (+) net operating surplus of households and NPISH | B2n | S14+S15 |
| `prico` | (+) net primary income of corporations | B5n | S11+S12 |
| `nmxho` | (+) net mixed income of households | B3n | S14 |
| `ptxgo` | (+) taxes on products and production | D2-D3 | S13 |

Mixed income is conventionally split 70% labor / 30% capital for computing factor shares. The full four-way decomposition (pure labor, pure capital, mixed income, production taxes) is available when the treatment of mixed income matters.

### 3.1.6 Income Decomposition by Institutional Sector

**Factor-Price GDP Decomposition**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `gdpro` | (=) gross domestic product at market prices | B1g | S1 |
| `ptxgo` | (+) net taxes on products and production | D2-D3 | S1 |
| `gvato` | (+) gross domestic product at factor-price | B1g | S1 |
| `gvago` | (+) gross value added of the government | B1g | S13 |
| `ceugo` | (+) compensation of employees of the government | D1 | S13 |
| `gsrgo` | (+) gross operating surplus of the government | B2g | S13 |
| `nsrgo` | (+) net operating surplus of the government (=0) | B2n | S13 |
| `cfcgo` | (+) CFC of the government | P51c | S13 |
| `gvaco` | (+) gross value added of the corporate sector | B1g | S11+S12 |
| `ceuco` | (+) compensation of employees of the corporate sector | D1 | S11+S12 |
| `gsrco` | (+) gross operating surplus of the corporate sector | B2g | S11+S12 |
| `nsrco` | (+) net operating surplus of the corporate sector | B2n | S11+S12 |
| `cfcco` | (+) CFC of the corporate sector | P51c | S11+S12 |
| `gvahn` | (+) gross value added of household sector | B1g | S14+S15 |
| `ceuhn` | (+) compensation of employees of household sector | D1 | S14+S15 |
| `gmxhn` | (+) gross mixed income of household sector | B3g | S14+S15 |
| `nmxhn` | (+) net mixed income of household sector | B3n | S14+S15 |
| `ccmhn` | (+) CFC of mixed income of household sector | P51c | S14+S15 |
| `gsrhn` | (+) gross operating surplus of household sector | B2g | S14+S15 |
| `nsrhn` | (+) net operating surplus of household sector | B2n | S14+S15 |
| `ccshn` | (+) CFC of operating surplus of household sector | P51c | S14+S15 |

**Factor Shares**

| WID code | Description | SNA sector |
|----------|-------------|------------|
| `ylsgdp` | labor share of gross domestic product at factor-price | S1 |
| `ylsndp` | labor share of net domestic product at factor-price | S1 |
| `ycsgdp` | capital share of gross domestic product at factor-price | S1 |
| `ycsndp` | capital share of net domestic product at factor-price | S1 |
| `wlsgni` | labor share of gross national income at factor-price | S1 |
| `wlsnni` | labor share of national income at factor-price | S1 |
| `wcsgni` | capital share of gross national income at factor-price | S1 |
| `wcsnni` | capital share of national income at factor-price | S1 |
| `ylscgv` | labor share in corporate gross value added at factor-price | S11+S12 |
| `ylscnv` | labor share in corporate net value added at factor-price | S11+S12 |
| `ycscgv` | capital share in corporate gross value added at factor-price | S11+S12 |
| `ycscnv` | capital share in corporate net value added at factor-price | S11+S12 |

---

## 3.2 Income of Households and NPISH

Variables with suffix `hn` = households and NPISH combined; `ho` = households only; `np` = NPISH only.

### 3.2.1 Income of the Sectors Combined

#### 3.2.1.1 Primary Incomes of Households and NPISH

**Net of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `prihn` | (=) net primary income of households and NPISH | B5n | S14+S15 |
| `comhn` | (+) compensation of employees | D1 | S14+S15 |
| `prphn` | (+) property income (net) | D4 | S14+S15 |
| `nsmhn` | (+) net operating surplus and mixed income | B2n+B3n | S14+S15 |
| `nsrhn` | (+) net operating surplus | B2n | S14+S15 |
| `nmxhn` | (+) net mixed income | B3n | S14+S15 |

**Gross of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `prghn` | (=) gross primary income of households and NPISH | B5n | S14+S15 |
| `comhn` | (+) compensation of employees | D1 | S14+S15 |
| `prphn` | (+) property income (net) | D4 | S14+S15 |
| `gsmhn` | (+) gross operating surplus and mixed income | B2g+B3g | S14+S15 |
| `gsrhn` | (+) gross operating surplus | B2g | S14+S15 |
| `gmxhn` | (+) gross mixed income | B3g | S14+S15 |

#### 3.2.1.2 Secondary Incomes of Households and NPISH

**Net of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `sechn` | (=) net secondary income of households and NPISH | B6n+D7 | S14+S15 |
| `prihn` | (+) net primary income of households and NPISH | D1 | S14+S15 |
| `taxhn` | (-) direct taxes | D5+D61 | S14+S15 |
| `sschn` | (+) social contributions | D61 | S14+S15 |
| `tiwhn` | (+) personal taxes on income and wealth | D5 | S14+S15 |
| `ssbhn` | (+) social benefits other than social transfers in kind | D62 | S14+S15 |

**Gross of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `seghn` | (=) gross secondary income of households and NPISH | B6n+D7 | S14+S15 |
| `prghn` | (+) gross primary income of households and NPISH | D1 | S14+S15 |
| `taxhn` | (-) direct taxes | D5+D61 | S14+S15 |
| `sschn` | (+) social contributions | D61 | S14+S15 |
| `tiwhn` | (+) personal taxes on income and wealth | D5 | S14+S15 |
| `ssbhn` | (+) social benefits other than social transfers in kind | D62 | S14+S15 |

#### 3.2.1.3 Consumption and Savings of Households and NPISH

**Net of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `savhn` | (=) net savings of households and NPISH | B8n+D7 | S14+S15 |
| `sechn` | (+) net secondary income of households and NPISH | B6n+D7 | S14+S15 |
| `conhn` | (-) private expenditures of households and NPISH | P3 | S14+S15 |

**Gross of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `saghn` | (=) gross savings of households and NPISH | B8n+D7 | S14+S15 |
| `seghn` | (+) gross secondary income of households and NPISH | B6n+D7 | S14+S15 |
| `conhn` | (-) private expenditures of households and NPISH | P3 | S14+S15 |

#### 3.2.1.4 Relation between Net and Gross Variables

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `prghn` | (=) gross primary income of households and NPISH | B5g | S14+S15 |
| `prihn` | (+) net primary income of households and NPISH | B5n | S14+S15 |
| `cfchn` | (+) consumption of fixed capital | P51c | S14+S15 |
| `seghn` | (=) gross secondary income of households and NPISH | B6g+D7 | S14+S15 |
| `sechn` | (+) net secondary income of households and NPISH | B6n+D7 | S14+S15 |
| `cfchn` | (+) consumption of fixed capital | P51c | S14+S15 |
| `saghn` | (=) gross savings of households and NPISH | B8g+D7 | S14+S15 |
| `savhn` | (+) net savings of households and NPISH | B8n+D7 | S14+S15 |
| `cfchn` | (+) consumption of fixed capital | P51c | S14+S15 |
| `gsmhn` | (=) gross surplus and mixed income of households and NPISH | B2g+B3g | S14+S15 |
| `nsmhn` | (+) net surplus and mixed income of households and NPISH | B2n+B3n | S14+S15 |
| `cfchn` | (+) consumption of fixed capital | P51c | S14+S15 |
| `gsrhn` | (=) gross surplus of households and NPISH | B2g | S14+S15 |
| `nsrhn` | (+) net surplus of households and NPISH | B2n | S14+S15 |
| `ccshn` | (+) CFC attributable to operating surplus | | |
| `gmxhn` | (=) gross mixed income of households and NPISH | B3g | S14+S15 |
| `nmxhn` | (+) net mixed income of households and NPISH | B3n | S14+S15 |
| `ccmhn` | (+) CFC attributable to mixed income | | |
| `cfchn` | (=) consumption of fixed capital | P51c | S14+S15 |
| `ccshn` | (+) CFC attributable to operating surplus | | |
| `ccmhn` | (+) CFC attributable to mixed income | | |

### 3.2.2 Income of Households

#### 3.2.2.1 Primary Incomes of the Household Sector

**Net of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `priho` | (=) net primary income of households | B5n | S14 |
| `comho` | (+) compensation of employees | D1 | S14 |
| `prpho` | (+) property income (net) | D4 | S14 |
| `nsmho` | (+) net operating surplus and mixed income | B2n+B3n | S14 |
| `nsrho` | (+) net operating surplus | B2n | S14 |
| `nmxho` | (+) net mixed income | B3n | S14 |

**Gross of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `prgho` | (=) gross primary income of households | B5n | S14 |
| `comho` | (+) compensation of employees | D1 | S14 |
| `prpho` | (+) property income (net) | D4 | S14 |
| `gsmho` | (+) gross operating surplus and mixed income | B2g+B3g | S14 |
| `gsrho` | (+) gross operating surplus | B2g | S14 |
| `gmxho` | (+) gross mixed income | B3g | S14 |

#### 3.2.2.2 Secondary Incomes of the Household Sector

**Net of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `secho` | (=) net secondary income of households | B6n+D7 | S14 |
| `priho` | (+) net primary income of households | D1 | S14 |
| `taxho` | (-) direct taxes | D5+D61 | S14 |
| `sscho` | (+) social contributions | D61 | S14 |
| `tiwho` | (+) personal taxes on income and wealth | D5 | S14 |
| `ssbho` | (+) social benefits other than social transfers in kind | D62 | S14 |

**Gross of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `segho` | (=) gross secondary income of households | B6n+D7 | S14 |
| `prgho` | (+) gross primary income of households | D1 | S14 |
| `taxho` | (-) direct taxes | D5+D61 | S14 |
| `sscho` | (+) social contributions | D61 | S14 |
| `tiwho` | (+) personal taxes on income and wealth | D5 | S14 |
| `ssbho` | (+) social benefits other than social transfers in kind | D62 | S14 |

#### 3.2.2.3 Consumption and Savings of the Household Sector

**Net of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `savho` | (=) net savings of households | B8n+D7 | S14 |
| `secho` | (+) net secondary income of households | B6n+D7 | S14 |
| `conho` | (-) private expenditures of households | P3 | S14 |

**Gross of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `sagho` | (=) gross savings of households | B8n+D7 | S14 |
| `segho` | (+) gross secondary income of households | B6n+D7 | S14 |
| `conho` | (-) private expenditures of households | P3 | S14 |

#### 3.2.2.4 Relation between Net and Gross Variables

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `prgho` | (=) gross primary income of households | B5g | S14 |
| `priho` | (+) net primary income of households | B5n | S14 |
| `cfcho` | (+) consumption of fixed capital | P51c | S14 |
| `segho` | (=) gross secondary income of households | B6g+D7 | S14 |
| `secho` | (+) net secondary income of households | B6n+D7 | S14 |
| `cfcho` | (+) consumption of fixed capital | P51c | S14 |
| `sagho` | (=) gross savings of households | B8g+D7 | S14 |
| `savho` | (+) net savings of households | B8n+D7 | S14 |
| `cfcho` | (+) consumption of fixed capital | P51c | S14 |
| `gsmho` | (=) gross surplus and mixed income of households | B2g+B3g | S14 |
| `nsmho` | (+) net surplus and mixed income of households | B2n+B3n | S14 |
| `cfcho` | (+) consumption of fixed capital | P51c | S14 |
| `gsrho` | (=) gross surplus of households | B2g | S14 |
| `nsrho` | (+) net surplus of households | B2n | S14 |
| `ccsho` | (+) CFC attributable to operating surplus | | |
| `gmxho` | (=) gross mixed income of households | B3g | S14 |
| `nmxho` | (+) net mixed income of households | B3n | S14 |
| `ccmho` | (+) CFC attributable to mixed income | | |
| `cfcho` | (=) consumption of fixed capital | P51c | S14 |
| `ccsho` | (+) CFC attributable to operating surplus | | |
| `ccmho` | (+) CFC attributable to mixed income | | |

### 3.2.3 Income of NPISH

#### 3.2.3.1 Primary Incomes of NPISH

**Net of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `prinp` | (=) net primary income of NPISH | B5n | S15 |
| `comnp` | (+) compensation of employees | D1 | S15 |
| `prpnp` | (+) property income (net) | D4 | S15 |
| `nsrnp` | (+) net operating surplus | B2n | S15 |

**Gross of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `prgnp` | (=) gross primary income of NPISH | B5n | S15 |
| `comnp` | (+) compensation of employees | D1 | S15 |
| `prpnp` | (+) property income (net) | D4 | S15 |
| `gsrnp` | (+) gross operating surplus | B2g | S15 |

#### 3.2.3.2 Secondary Incomes of NPISH

**Net of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `secnp` | (=) net secondary income of NPISH | B6n+D7 | S15 |
| `prinp` | (+) net primary income of NPISH | D1 | S15 |
| `taxnp` | (-) direct taxes | D5+D61 | S15 |
| `sscnp` | (+) social contributions | D61 | S15 |
| `tiwnp` | (+) personal taxes on income and wealth | D5 | S15 |
| `ssbnp` | (+) social benefits other than social transfers in kind | D62 | S15 |

**Gross of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `segnp` | (=) gross secondary income of NPISH | B6n+D7 | S15 |
| `prgnp` | (+) gross primary income of NPISH | D1 | S15 |
| `taxnp` | (-) direct taxes | D5+D61 | S15 |
| `sscnp` | (+) social contributions | D61 | S15 |
| `tiwnp` | (+) personal taxes on income and wealth | D5 | S15 |
| `ssbnp` | (+) social benefits other than social transfers in kind | D62 | S15 |

#### 3.2.3.3 Consumption and Savings of NPISH

**Net of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `savnp` | (=) net savings of NPISH | B8n+D7 | S15 |
| `secnp` | (+) net secondary income of NPISH | B6n+D7 | S15 |
| `connp` | (-) private expenditures of NPISH | P3 | S15 |

**Gross of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `sagnp` | (=) gross savings of NPISH | B8n+D7 | S15 |
| `segnp` | (+) gross secondary income of NPISH | B6n+D7 | S15 |
| `connp` | (-) private expenditures of NPISH | P3 | S15 |

#### 3.2.3.4 Relation between Net and Gross Variables

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `prgnp` | (=) gross primary income of NPISH | B5g | S15 |
| `prinp` | (+) net primary income of NPISH | B5n | S15 |
| `cfcnp` | (+) consumption of fixed capital | P51c | S15 |
| `segnp` | (=) gross secondary income of NPISH | B6g+D7 | S15 |
| `secnp` | (+) net secondary income of NPISH | B6n+D7 | S15 |
| `cfcnp` | (+) consumption of fixed capital | P51c | S15 |
| `sagnp` | (=) gross savings of NPISH | B8g+D7 | S15 |
| `savnp` | (+) net savings of NPISH | B8n+D7 | S15 |
| `cfcnp` | (+) consumption of fixed capital | P51c | S15 |
| `gsrnp` | (=) gross surplus of NPISH | B2g | S15 |
| `nsrnp` | (+) net surplus of NPISH | B2n | S15 |
| `cfcnp` | (+) CFC attributable to operating surplus | | |

---

## 3.3 Income of the Corporate Sector

### 3.3.1 Income of the Sectors Combined

#### 3.3.1.1 Primary Income of Corporations

**Net of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `prico` | (=) net primary income of corporations | B5n | S11+S12 |
| `prpco` | (+) property income (net) | D4 | S11+S12 |
| `nsrco` | (+) net operating surplus | B2n | S11+S12 |

**Gross of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `prgco` | (=) gross primary income of corporations | B5g | S11+S12 |
| `prpco` | (+) property income (net) | D4 | S11+S12 |
| `gsrco` | (+) gross operating surplus | B2g | S11+S12 |

#### 3.3.1.2 Secondary Income of Corporations

For corporations, secondary income equals net saving (corporations have no consumption expenditure).

**Net of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `secco` | (=) net secondary income / net saving of corporations | B6n+D7 | S11+S12 |
| `prico` | (+) net primary income of corporations | B5n | S11+S12 |
| `taxco` | (-) corporate tax | D5 | S11+S12 |
| `sscco` | (+) social contributions to private employer social insurance | D61 | S11+S12 |
| `ssbco` | (-) social benefits from private employer social insurance | D62 | S11+S12 |

**Gross of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `segco` | (=) gross secondary income / gross saving of corporations | B6g+D7 | S11+S12 |
| `prgco` | (+) gross primary income of corporations | B5g | S11+S12 |
| `taxco` | (-) corporate tax | D5 | S11+S12 |
| `sscco` | (+) social contributions to private employer social insurance | D61 | S11+S12 |
| `ssbco` | (-) social benefits from private employer social insurance | D62 | S11+S12 |

#### 3.3.1.3 Relation between Net and Gross Variables

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `prgco` | (=) gross primary income of corporations | B5g | S11+S12 |
| `prico` | (+) net primary income of corporations | B5n | S11+S12 |
| `cfcco` | (+) consumption of fixed capital | P51c | S11+S12 |
| `segco` | (=) gross secondary income / gross saving of corporations | B6g+D7 | S11+S12 |
| `secco` | (+) net secondary income / net saving of corporations | B6n+D7 | S11+S12 |
| `cfcco` | (+) consumption of fixed capital | P51c | S11+S12 |

### 3.3.2 Income of Non-financial Corporations

#### 3.3.2.1 Primary Income

**Net of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `prinf` | (=) net primary income of non-financial corporations | B5n | S11 |
| `prpnf` | (+) property income (net) | D4 | S11 |
| `nsrnf` | (+) net operating surplus | B2n | S11 |

**Gross of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `prgnf` | (=) gross primary income of non-financial corporations | B5g | S11 |
| `prpnf` | (+) property income (net) | D4 | S11 |
| `gsrnf` | (+) gross operating surplus | B2g | S11 |

#### 3.3.2.2 Secondary Income

**Net of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `secnf` | (=) net secondary income / net saving of non-financial corporations | B6n+D7 | S11 |
| `prinf` | (+) net primary income of non-financial corporations | B5n | S11 |
| `taxnf` | (-) corporate tax | D5 | S11 |
| `sscnf` | (+) social contributions to private employer social insurance | D61 | S11 |
| `ssbnf` | (-) social benefits from private employer social insurance | D62 | S11 |

**Gross of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `segnf` | (=) gross secondary income / gross saving of non-financial corporations | B6g+D7 | S11 |
| `prgnf` | (+) gross primary income of non-financial corporations | B5g | S11 |
| `taxnf` | (-) corporate tax | D5 | S11 |
| `sscnf` | (+) social contributions to private employer social insurance | D61 | S11 |
| `ssbnf` | (-) social benefits from private employer social insurance | D62 | S11 |

#### 3.3.2.3 Relation between Net and Gross Variables

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `prgnf` | (=) gross primary income of non-financial corporations | B5g | S11 |
| `prinf` | (+) net primary income of non-financial corporations | B5n | S11 |
| `cfcnf` | (+) consumption of fixed capital | P51c | S11 |
| `segnf` | (=) gross secondary income / gross saving of non-financial corporations | B6g+D7 | S11 |
| `secnf` | (+) net secondary income / net saving of non-financial corporations | B6n+D7 | S11 |
| `cfcnf` | (+) consumption of fixed capital | P51c | S11 |

### 3.3.3 Income of Financial Corporations

#### 3.3.3.1 Primary Income

**Net of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `prifc` | (=) net primary income of financial corporations | B5n | S12 |
| `prpfc` | (+) property income (net) | D4 | S12 |
| `nsrfc` | (+) net operating surplus | B2n | S12 |

**Gross of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `prgfc` | (=) gross primary income of financial corporations | B5g | S12 |
| `prpfc` | (+) property income (net) | D4 | S12 |
| `gsrfc` | (+) gross operating surplus | B2g | S12 |

#### 3.3.3.2 Secondary Income

**Net of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `secfc` | (=) net secondary income / net saving of financial corporations | B6n+D7 | S12 |
| `prifc` | (+) net primary income of financial corporations | B5n | S12 |
| `taxfc` | (-) corporate tax | D5 | S12 |
| `sscfc` | (+) social contributions to private employer social insurance | D61 | S12 |
| `ssbfc` | (-) social benefits from private employer social insurance | D62 | S12 |

**Gross of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `segfc` | (=) gross secondary income / gross saving of financial corporations | B6g+D7 | S12 |
| `prgfc` | (+) gross primary income of financial corporations | B5g | S12 |
| `taxfc` | (-) corporate tax | D5 | S12 |
| `sscfc` | (+) social contributions to private employer social insurance | D61 | S12 |
| `ssbfc` | (-) social benefits from private employer social insurance | D62 | S12 |

#### 3.3.3.3 Relation between Net and Gross Variables

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `prgfc` | (=) gross primary income of financial corporations | B5g | S12 |
| `prifc` | (+) net primary income of financial corporations | B5n | S12 |
| `cfcfc` | (+) consumption of fixed capital | P51c | S12 |
| `segfc` | (=) gross secondary income / gross saving of financial corporations | B6g+D7 | S12 |
| `secfc` | (+) net secondary income / net saving of financial corporations | B6n+D7 | S12 |
| `cfcfc` | (+) consumption of fixed capital | P51c | S12 |

---

## 3.4 Income of the Government Sector

### 3.4.1 Primary Income of the Government

**Net of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `prigo` | (=) net primary income of the general government | B5n | S13 |
| `ptxgo` | (+) taxes on production and imports, less subsidies | D2-D3 | S13 |
| `tpigo` | (+) taxes on production and imports | D2 | S13 |
| `tprgo` | (+) taxes on products | D21 | S13 |
| `otpgp` | (+) other taxes on production | D29 | S13 |
| `spigo` | (-) subsidies on production and imports | D3 | S13 |
| `sprgo` | (+) subsidies on products | D31 | S13 |
| `ospgo` | (+) other subsidies on production | D39 | S13 |
| `prpgo` | (+) property income (net) | D4 | S13 |
| `nsrgo` | (+) net operating surplus and miscellaneous | B2n | S13 |

**Gross of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `prggo` | (=) gross primary income of the general government | B5n | S13 |
| `ptxgo` | (+) taxes on production and imports, less subsidies | D2-D3 | S13 |
| `tpigo` | (+) taxes on production and imports | D2 | S13 |
| `tprgo` | (+) taxes on products | D21 | S13 |
| `otpgp` | (+) other taxes on production | D29 | S13 |
| `spigo` | (-) subsidies on production and imports | D3 | S13 |
| `sprgo` | (+) subsidies on products | D31 | S13 |
| `ospgo` | (+) other subsidies on production | D39 | S13 |
| `prpgo` | (+) property income (net) | D4 | S13 |
| `gsrgo` | (+) gross operating surplus and miscellaneous | B2n | S13 |

### 3.4.2 Secondary Income of the Government

**Net of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `secgo` | (=) net secondary income of the general government | B6n+D7 | S13 |
| `prigo` | (+) net primary income of the general government | B5n | S13 |
| `taxgo` | (+) direct taxes | D5+D61 | S13 |
| `tiwgo` | (+) direct taxes on income and wealth | D5 | S13 |
| `sscgo` | (+) social contributions | D61 | S13 |
| `ssbgo` | (-) social benefits other than social transfers in kind | D62 | S13 |

**Gross of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `seggo` | (=) gross secondary income of the general government | B6n+D7 | S13 |
| `prggo` | (+) gross primary income of the general government | B5n | S13 |
| `taxgo` | (+) direct taxes | D5+D61 | S13 |
| `tiwgo` | (+) direct taxes on income and wealth | D5 | S13 |
| `sscgo` | (+) social contributions | D61 | S13 |
| `ssbgo` | (-) social benefits other than social transfers in kind | D62 | S13 |

### 3.4.3 Consumption and Savings of the Government

**Net of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `savgo` | (=) net savings of the general government | B8n+D7 | S13 |
| `secgo` | (+) net secondary income of the general government | B6n+D7 | S13 |
| `congo` | (-) final consumption expenditures | P3 | S13 |
| `indgo` | (+) individual consumption expenditures | P31 | S13 |
| `colgo` | (+) collective consumption expenditure | P32 | S13 |

**Gross of Consumption of Fixed Capital**

| WID code | Description | SNA code | SNA sector |
|----------|-------------|----------|------------|
| `saggo` | (=) gross savings of the general government | B8n+D7 | S13 |
| `seggo` | (+) gross secondary income of the general government | B6n+D7 | S13 |
| `congo` | (-) final consumption expenditures | P3 | S13 |
| `indgo` | (+) individual consumption expenditures | P31 | S13 |
| `colgo` | (+) collective consumption expenditure | P32 | S13 |

**Government Spending by Function**

| WID code | Description | SNA sector |
|----------|-------------|------------|
| `congo` | (=) final consumption expenditures | S13 |
| `gpsgo` | (+) general public services | S13 |
| `defgo` | (+) defense | S13 |
| `polgo` | (+) public order and safety | S13 |
| `ecogo` | (+) economic affairs | S13 |
| `envgo` | (+) environment protection | S13 |
| `hougo` | (+) housing and community amenities | S13 |
| `heago` | (+) health | S13 |
| `recgo` | (+) recreation, culture and religion | S13 |
| `edugo` | (+) education | S13 |
| `sopgo` | (+) social protection | S13 |
| `othgo` | (+) other government spending | S13 |

**Government Expenditure by Function**

| WID code | Description | SNA sector |
|----------|-------------|------------|
| `expgo` | (=) total public spending (excl. interest payment) | S13 |
| `gpsge` | (+) general public services (excl. interest payment) | S13 |
| `defge` | (+) defense | S13 |
| `polge` | (+) public order and safety | S13 |
| `ecoge` | (+) economic affairs | S13 |
| `envge` | (+) environment protection | S13 |
| `houge` | (+) housing and community amenities | S13 |
| `heage` | (+) health | S13 |
| `recge` | (+) recreation, culture and religion | S13 |
| `eduge` | (+) education | S13 |
| `edpge` | (+) education: primary | S13 |
| `edsge` | (+) education: secondary | S13 |
| `edtge` | (+) education: tertiary | S13 |
| `sopge` | (+) social protection | S13 |
| `spige` | (+) social protection: social insurance | S13 |
| `sacge` | (+) social protection: social assistance in cash | S13 |
| `sakge` | (+) social protection: social assistance in kind | S13 |

**Government Revenue**

| WID code | Description | SNA sector |
|----------|-------------|------------|
| `revgo` | (=) total public revenue | S13 |
| `pitgr` | (+) personal income tax | S13 |
| `citgr` | (+) corporate income tax | S13 |
| `scogr` | (+) social contributions | S13 |
| `pwtgr` | (+) property and wealth taxes | S13 |
| `intgr` | (+) indirect taxes | S13 |
| `ottgr` | (+) other taxes | S13 |
| `ntrgr` | (+) non-tax revenue | S13 |
| `retgo` | (=) total public revenue (excl. non-tax revenue) | S13 |
| `psugo` | (=) primary surplus of the government | S13 |
| `ssugo` | (=) secondary surplus of the government | S13 |
| `inpgo` | (-) interest paid by the government | S13 |

---

## 3.5 Current Account

| WID code | Description |
|----------|-------------|
| `ncanx` | (=) Current Account = pinnx + comnx + tbnnx + taxnx + scinx |
| `pinnx` | (+) net foreign capital income |
| `pinrx` | (+) property income received from the rest of the world |
| `pinpx` | (-) property income paid to the rest of the world |
| `comnx` | (+) net foreign labor income |
| `comrx` | (+) compensation of employees received |
| `compx` | (-) compensation of employees paid |
| `tbnnx` | (+) trade balance (exports - imports) |
| `tbxrx` | (+) exports of goods and services |
| `tbmpx` | (-) imports of goods and services |
| `taxnx` | (+) foreign subsidies less taxes on production and imports |
| `fsubx` | (+) subsidies on prod. received from rest of world |
| `ftaxx` | (-) taxes on prod. paid to rest of world |
| `scinx` | (+) net foreign transfers |
| `scirx` | (+) foreign transfers received from rest of world |
| `scipx` | (-) foreign transfers paid to rest of world |

### 3.5.1 Trade Balance

| WID code | Description |
|----------|-------------|
| `tbnnx` | (=) trade balance (exports - imports) |
| `tgnnx` | (+) trade balance of goods (exports - imports) |
| `tgxrx` | (+) exports of goods |
| `tgmpx` | (-) imports of goods |
| `tsnnx` | (+) trade balance of services (exports - imports) |
| `tsxrx` | (+) exports of services |
| `tsmpx` | (-) imports of services |

### 3.5.2 Trade Balance of Services

| WID code | Description |
|----------|-------------|
| `tsnnx` | (=) trade balance of services (exports - imports) |
| `tsvnx` | (+) trade balance of travel services (exports - imports) |
| `tsvrx` | (+) exports of travel services |
| `tsvpx` | (-) imports of travel services |
| `tstnx` | (+) trade balance of transport services (exports - imports) |
| `tstrx` | (+) exports of transport services |
| `tstpx` | (-) imports of transport services |
| `tsonx` | (+) trade balance of other services (exports - imports) |
| `tsorx` | (+) exports of other services |
| `tsopx` | (-) imports of other services |

### 3.5.3 Trade Balance of Goods

| WID code | Description |
|----------|-------------|
| `tgnnx` | (=) trade balance of goods (exports - imports) |
| `tgncx` | (+) trade balance of primary commodities (exports - imports) |
| `tgxcx` | (+) exports of primary commodities |
| `tgmcx` | (-) imports of primary commodities |
| `tgnmx` | (+) trade balance of manufacturing goods (exports - imports) |
| `tgxmx` | (+) exports of manufacturing goods |
| `tgmmx` | (-) imports of manufacturing goods |

### 3.5.4 Capital Account

| WID code | Description |
|----------|-------------|
| `fkanx` | (=) capital account |
| `fkarx` | (+) capital transfers received from the rest of the world |
| `fkapx` | (-) capital transfers paid to the rest of the world |

### 3.5.5 Net Foreign Transfers

| WID code | Description |
|----------|-------------|
| `scinx` | (+) net foreign transfers |
| `scrnx` | (+) net remittances |
| `scrrx` | (+) remittances received from rest of world |
| `scrpx` | (-) remittances paid to rest of world |
| `scgnx` | (+) net public foreign transfers |
| `scgrx` | (+) public foreign transfers received from rest of world |
| `scgpx` | (-) public foreign transfers paid to rest of world |
| `sconx` | (+) net other foreign transfers |
| `scorx` | (+) other foreign transfers received from rest of world |
| `scopx` | (-) other foreign transfers paid to rest of world |

---

## 4. Distributed Income Variables

```{r dist-income}
# Top 1% pretax income share
download_wid(
  indicators = "sptinc992j",
  areas      = c("US", "FR", "CN", "ZA"),
  perc       = "p99p100",
  years      = 1990:2023
)

# Gini from full distribution
dist <- download_wid("sptinc992j", areas = "US", perc = "all", years = 2022)
wid_gini(dist)
wid_top_share(dist, top = 0.01)

# Percentile ratio from threshold series
thresh <- download_wid("tptinc992j", areas = "US", perc = "all", years = 2022)
wid_percentile_ratio(thresh)

# Plot Lorenz curve
wid_plot_lorenz(dist)
```

### 4.1 DINA Income

DINA income concepts are consistent with national accounts aggregates. Each five-letter code is associated with a concept (income attributed) and a ranking variable (income used to rank individuals -- sometimes identical, sometimes not).

#### 4.1.1 Pretax Income

Pretax income includes social insurance benefits (removing corresponding contributions) but excludes other redistribution.

| WID code | Description | Ranking variable |
|----------|-------------|-----------------|
| `ptinc` | (=) pretax national income | pretax national income |
| `ptlin` | (+) pretax labor income | |
| `ptkin` | (+) pretax capital income | |
| `pllin` | (+) pretax labor income | pretax labor income |
| `pkkin` | (+) pretax capital income | pretax capital income |

#### 4.1.2 Post-tax Income

| WID code | Description | Ranking variable |
|----------|-------------|-----------------|
| `diinc` | (=) post-tax national income | post-tax national income |
| `cainc` | (=) post-tax disposable income | post-tax disposable income |

#### 4.1.3 Factor Income

Factor income measures inequality before any redistribution (before social insurance or social assistance). Sensitive to age structure -- use with care for international comparisons.

| WID code | Description | Ranking variable |
|----------|-------------|-----------------|
| `fainc` | (=) factor national income | factor national income |
| `flinc` | (=) labor factor income | labor factor income |

### 4.2 "Fiscal" Income

Fiscal income is a legacy concept from the World Top Income Database (WTID). It is close to taxable income; its exact definition varies by country and over time. In most cases, fiscal income is only available for the top 10% of the distribution.

```{r fiscal}
download_wid(
  indicators = "sfiinc992j",
  areas      = "US",
  perc       = "p99p100",
  years      = 1913:2023
)
```

| WID code | Description | Ranking variable |
|----------|-------------|-----------------|
| `fiinc` | (=) fiscal income | total fiscal income |
| `filin` | (+) fiscal labor income | |
| `fiwag` | (+) wages and pensions | |
| `fimil` | (+) labor component of mixed-income | |
| `ficap` | (+) fiscal capital income | |
| `firen` | (+) rents | |
| `fiint` | (+) interests | |
| `fidiv` | (+) dividends | |
| `fikgi` | (+) capital gains | |
| `fimik` | (+) capital component of mixed-income | |
| `fimix` | (=) mixed-income | total fiscal income |

---

## 5. Aggregate Wealth Variables

### 5.1 National Economy

```{r wealth-national}
download_wid(indicators = "mnweal999i", areas = "FR", years = 1970:2023)
```

| WID code | Description |
|----------|-------------|
| `nweal` | (=) net market-value national wealth |
| `nwnfa` | (+) national non-financial assets |
| `nwhou` | (+) national housing assets |
| `nwdwe` | (+) dwellings |
| `nwlan` | (+) land underlying dwellings |
| `nwbus` | (+) national business and other non-financial assets |
| `nwagr` | (+) agricultural land |
| `nwodk` | (+) other domestic capital |
| `nwnxa` | (+) net foreign assets |
| `nwgxa` | (+) gross foreign assets |
| `nwgxd` | (-) gross foreign liabilities |
| `nwboo` | (=) book-value national wealth |
| `nweal` | (+) net national wealth |
| `cwres` | (+) residual corporate wealth |
| `nwdka` | (=) domestic capital |
| `nweal` | (+) net national wealth |
| `nwnxa` | (-) net foreign assets |

### 5.2 Households and NPISH

#### 5.2.1 Combined Sector (Private Wealth)

| WID code | Description |
|----------|-------------|
| `pweal` | (=) private net wealth |
| `pwnfa` | (+) private non-financial assets |
| `pwhou` | (+) private housing assets |
| `pwdwe` | (+) dwellings |
| `pwlan` | (+) land underlying dwellings |
| `pwbus` | (+) private business and other non-financial assets |
| `pwagr` | (+) agricultural land |
| `pwodk` | (+) other domestic capital |
| `pwfin` | (+) financial assets |
| `pwfiw` | (+) currency, deposits, bonds, and loans |
| `pwcud` | (+) currency and deposits |
| `pwbol` | (+) bonds and loans |
| `pweqi` | (+) equities and fund shares |
| `pwoff` | (+) offshore wealth |
| `pwpen` | (+) pension funds and life insurance |
| `pwdeb` | (-) liabilities |
| `pwfie` | (=) financial assets except for currency and deposits |

#### 5.2.2 Household Sector

| WID code | Description |
|----------|-------------|
| `hweal` | (=) household net wealth |
| `hwnfa` | (+) household non-financial assets |
| `hwhou` | (+) household housing assets |
| `hwdwe` | (+) dwellings |
| `hwlan` | (+) land underlying dwellings |
| `hwbus` | (+) household business and other non-financial assets |
| `hwagr` | (+) agricultural land |
| `hwodk` | (+) other domestic capital |
| `hwfin` | (+) financial assets |
| `hwfiw` | (+) currency, deposits, bonds, and loans |
| `hwcud` | (+) currency and deposits |
| `hwbol` | (+) bonds and loans |
| `hweqi` | (+) equities and fund shares |
| `hwpen` | (+) pension funds and life insurance |
| `hwdeb` | (-) liabilities |
| `hwfie` | (=) financial assets except for currency and deposits |

#### 5.2.3 NPISH

| WID code | Description |
|----------|-------------|
| `iweal` | (=) non-profit institutions' net wealth |
| `iwnfa` | (+) non-profit institutions' non-financial assets |
| `iwhou` | (+) non-profit institutions' housing assets |
| `iwdwe` | (+) dwellings |
| `iwlan` | (+) land underlying dwellings |
| `iwbus` | (+) non-profit institutions' business and other non-financial assets |
| `iwagr` | (+) agricultural land |
| `iwodk` | (+) other domestic capital |
| `iwfin` | (+) financial assets |
| `iwfiw` | (+) currency, deposits, bonds, and loans |
| `iwcud` | (+) currency and deposits |
| `iwbol` | (+) bonds and loans |
| `iweqi` | (+) equities and fund shares |
| `iwpen` | (+) pension funds and life insurance |
| `iwdeb` | (-) liabilities |
| `iwfie` | (=) financial assets except for currency and deposits |

### 5.3 Corporate Sector

Corporate sector wealth (assets minus debt) = book value. The ratio of market value to book value = Tobin's Q.

| WID code | Description |
|----------|-------------|
| `cwboo` | (=) book value of corporations |
| `cwnfa` | (+) corporate non-financial assets |
| `cwhou` | (+) corporate housing assets |
| `cwdwe` | (+) dwellings |
| `cwlan` | (+) land underlying dwellings |
| `cwbus` | (+) corporate business and other non-financial assets |
| `cwagr` | (+) agricultural land |
| `cwodk` | (+) other domestic capital |
| `cwfin` | (+) financial assets |
| `cwfiw` | (+) currency, deposits, bonds, and loans |
| `cwcud` | (+) currency and deposits |
| `cwbol` | (+) bonds and loans |
| `cweqi` | (+) equities and fund shares |
| `cwpen` | (+) pension funds and life insurance |
| `cwdeb` | (-) corporate debt (non-equity liability) |
| `cwdeq` | (=) market value of corporations (equity liability) |
| `cwboo` | (+) book value of corporations |
| `cwres` | (+) residual corporate wealth |
| `icwtoq` | (*) Tobin Q (market value / book value) |
| `cwfie` | (=) financial assets except for currency and deposits |

### 5.4 General Government Sector

| WID code | Description |
|----------|-------------|
| `gweal` | (=) net wealth of the general government |
| `gwnfa` | (+) government non-financial assets |
| `gwhou` | (+) government housing assets |
| `gwdwe` | (+) dwellings |
| `gwlan` | (+) land underlying dwellings |
| `gwbus` | (+) government business and other non-financial assets |
| `gwagr` | (+) agricultural land |
| `gwodk` | (+) other domestic capital |
| `gwfin` | (+) financial assets |
| `gwfiw` | (+) currency, deposits, bonds, and loans |
| `gwcud` | (+) currency and deposits |
| `gwbol` | (+) bonds and loans |
| `gweqi` | (+) equities and fund shares |
| `gwpen` | (+) pension funds and life insurance |
| `gwdeb` | (-) liabilities |
| `gwdec` | (=) consolidated government debt |
| `gwfie` | (=) financial assets except for currency and deposits |

To compute national liabilities, sum liabilities across all sectors: `mpwdeb + mcwdeb + mcwdeq + mgwdeb`.

---

## 6. Distributed Wealth Variables

The distributed wealth variables are identical to the aggregate wealth variables of the household sector. Individuals are ranked by net personal wealth.

```{r wealth-dist}
download_wid(
  indicators = "shweal992j",
  areas      = "GB",
  perc       = c("p90p100", "p99p100"),
  years      = 1995:2023)

wid_plot_lorenz(download_wid("shweal992j", areas = "US", perc = "all", years = 2019))
```

| WID code | Description |
|----------|-------------|
| `hweal` | (=) household net wealth |
| `hwnfa` | (+) household non-financial assets |
| `hwhou` | (+) household housing assets |
| `hwdwe` | (+) dwellings |
| `hwlan` | (+) land underlying dwellings |
| `hwbus` | (+) household business and other non-financial assets |
| `hwagr` | (+) agricultural land |
| `hwodk` | (+) other domestic capital |
| `hwfin` | (+) financial assets |
| `hwfiw` | (+) currency, deposits, bonds, and loans |
| `hwcud` | (+) currency and deposits |
| `hwbol` | (+) bonds and loans |
| `hweqi` | (+) equities and fund shares |
| `hwpen` | (+) pension funds and life insurance |
| `hwdeb` | (-) liabilities |
| `hwfie` | (=) financial assets except for currency and deposits |
| `hwfin` | (+) financial assets |
| `hwcud` | (-) currency and deposits |

---

## 7. Price Index, Exchange Rates, Populations, etc.

### 7.1 Price Index

The WID uses a single price index (`inyixx`) -- the national income deflator, typically the GDP deflator (CPI when unavailable). It equals 1 in the data's base year.

```{r price}
download_wid(indicators = "inyixx999i", areas = "US", years = 1950:2023)
```

| Full WID code | Description |
|--------------|-------------|
| `inyixx999i` | national income price index |
| `intlcu999i` | local currency unit change indicator |

### 7.2 Exchange Rates

The WID provides PPP conversion factors and market exchange rates for USD, EUR, and CNY. To convert between currencies in the benchmark approach, use only the last value of each series. `wid_convert()` handles this automatically.

```{r fx}
# Retrieve PPP exchange rate directly
download_wid(indicators = "xlcusp999i", areas = "FR", years = 2023)

# Convert a monetary series to 2022 USD PPP in one step
download_wid("aptinc992j", areas = c("US", "FR", "CN", "IN"), perc = "p0p50") |>
  wid_convert(target = "ppp", base_year = "2022")
```

Supported `wid_convert()` targets: `"lcu"` (no conversion), `"usd"`, `"eur"`, `"gbp"`, `"ppp"`, `"yppp"`. Dimensionless series (types `s`, `g`, `b`, `w`, `r`, `p`, `i`, `y`) are returned unchanged.

**PPP Conversion Factors**

| Full WID code | Description |
|--------------|-------------|
| `xlcusp999i` | LCU per USD |
| `xlceup999i` | LCU per EUR |
| `xlcyup999i` | LCU per CNY |

**Market Exchange Rates**

| Full WID code | Description |
|--------------|-------------|
| `xlcusx999i` | LCU per USD |
| `xlceux999i` | LCU per EUR |
| `xlcyux999i` | LCU per CNY |

**Real Exchange Rates** (PPP / market rate)

| Full WID code | Description |
|--------------|-------------|
| `xrerus999i` | real exchange rate between LCU and USD |
| `xrereu999i` | real exchange rate between LCU and EUR |
| `xreryu999i` | real exchange rate between LCU and CNY |

### 7.3 Population

```{r pop}
download_wid(indicators = "npopul999i", areas = "US", years = 1800:2023)
```

| Six-letter code | Description |
|----------------|-------------|
| `npopul` | population |
| `npopem` | employed population |
| `ntaxto` | total tax population |
| `ntaxma` | number of tax units -- married couples and single adults |
| `ntaxad` | number of tax units -- adults |
| `ntaxre` | number of tax returns |

Combined with age and population unit codes (e.g., `npopul992i` for adult population).

### 7.4 Wealth/Income Ratios and Labor/Capital Shares

| Full WID code | Description |
|--------------|-------------|
| `wlabsh999i` | labor share of factor-price national income |
| `wcapsh999i` | capital share of factor-price national income |
| `wwealn999i` | net national wealth to net national income ratio |
| `wwealp999i` | net private wealth to net national income ratio |
| `wwealh999i` | net personal wealth to net national income ratio |
| `wweali999i` | net non-profit wealth to net national income ratio |
| `wwealc999i` | net corporate wealth to net national income ratio |
| `wwealg999i` | net public wealth to net national income ratio |

### 7.5 Inequality Transparency

WID produces a single inequality transparency index per country, ranging from 0 to 20, weighting income and wealth data equally. Points are awarded for: income/consumption survey tabulations (1 pt), survey microdata (up to 3 pts), wealth survey tabulations (1 pt), wealth survey microdata (up to 3 pts), income tax tabulations for labor (1 pt) and capital (1 pt), income tax microdata for labor (2 pts) and capital (2 pts), wealth/estate tax tabulations (2 pts), and wealth/estate tax microdata (4 pts).

| Full WID code | Description |
|--------------|-------------|
| `iquali999i` | inequality transparency index (0-20) |

---

## 8. Aggregate Carbon Variables

### 8.1 National Territorial Emissions

| WID code | Description |
|----------|-------------|
| `ntghg` | (=) national territorial carbon emissions |
| `ntcar` | (+) national territorial CO2 emissions |
| `ntgho` | (+) national territorial emissions of other gases |
| `hfghd` | (+) household direct emissions |
| `ntgna` | (+) territorial emissions of national productive sector and other emissions not attributed to households |
| `ntcna` | (+) territorial emissions of national productive sector (CO2) |
| `ntona` | (+) territorial emissions of national productive sector (other gases) |

### 8.2 National Imported Emissions

| WID code | Description |
|----------|-------------|
| `nighg` | (=) national imported carbon emissions |
| `nicar` | (+) national imported CO2 emissions |
| `nigho` | (+) national imported emissions of other gases |
| `highg` | (+) household imported carbon emissions |
| `hicar` | (+) household imported CO2 emissions |
| `higho` | (+) household imported emissions of other gases |
| `gighg` | (+) government imported emissions |
| `gicar` | (+) government imported CO2 emissions |
| `gigho` | (+) government imported emissions of other gases |
| `iighg` | (+) investment imported carbon emissions |
| `iicar` | (+) investment imported CO2 emissions |
| `iigho` | (+) investment imported emissions of other gases |
| `oighg` | (+) NGO imported carbon emissions |
| `oicar` | (+) NGO imported CO2 emissions |
| `oigho` | (+) NGO imported emissions of other gases |

### 8.3 National Exported Emissions

| WID code | Description |
|----------|-------------|
| `neghg` | (=) national exported carbon emissions |
| `necar` | (+) national exported CO2 emissions |
| `negho` | (+) national exported emissions of other gases |

### 8.4 National Net Imports of Emissions

| WID code | Description |
|----------|-------------|
| `nnghg` | (=) national net imports of carbon emissions |
| `nncar` | (+) national net imports of CO2 emissions |
| `nngho` | (+) national net imports of other gases |

### 8.5 National Carbon Footprint

| WID code | Description |
|----------|-------------|
| `nfghg` | (=) national carbon footprint |
| `nfcar` | (+) national CO2 footprint |
| `nfgho` | (+) national footprint of other gases |
| `hfghg` | (+) household carbon footprint |
| `hfghd` | (+) household direct emissions |
| `hfghn` | (+) household indirect carbon footprint |
| `hfcar` | (+) household indirect CO2 footprint |
| `hfgho` | (+) household indirect footprint of other gases |
| `gfghg` | (+) government carbon footprint |
| `gfcar` | (+) government CO2 footprint |
| `gfgho` | (+) government footprint of other gases |
| `ifghg` | (+) investment carbon footprint |
| `ifcar` | (+) investment CO2 footprint |
| `ifgho` | (+) investment footprint of other gases |
| `ofghg` | (+) NGO carbon footprint |
| `ofcar` | (+) NGO CO2 footprint |
| `ofgho` | (+) NGO footprint of other gases |

```{r carbon-agg}
download_wid(indicators = "entghg999i", areas = "US", years = 1990:2023)
download_wid(indicators = "enfghg999i", areas = "US", years = 1990:2023)
```

---

## 9. Distributed Carbon Variables

Personal carbon footprints assign national carbon and CO2 footprints to income groups within countries, distinguishing between consumption-related and investment-related emissions.

```{r carbon-dist}
# WID canonical example: top 10% average per capita footprint, Switzerland 2014
download_wid(
  indicators = "lpfghg999i",
  areas      = "CH",
  perc       = "p90p100",
  years      = 2014)

# Bottom 50% share of emissions
download_wid(
  indicators = "spfghg999i",
  areas      = c("US", "FR", "IN"),
  perc       = "p0p50",
  years      = 2019)
```

| WID code | Description |
|----------|-------------|
| `pfcar` | (=) personal CO2 footprint |
| `pfghg` | (=) personal carbon footprint |
| `cfghg` | (+) personal carbon footprint (consumption only) |
| `ifghg` | (+) personal carbon footprint (investments only) |

Series types applicable to distributed carbon:

| Type | Example | Description |
|------|---------|-------------|
| `l` | `lpfghg999i` | average per capita group emissions |
| `e` | `epfghg999i` | total group emissions |
| `s` | `spfghg999i` | share of total emissions |
| `t` | `tpfghg999i` | threshold (minimum footprint to enter the group) |
| `k` | `kpfghg999i` | per capita emissions |

---

## 10. Quick Reference

`print.wid_df` and `print.wid_query` are S3 print methods; see `vignette("widr")` for display examples and full workflow demonstrations.

| Function | Purpose |
|----------|---------|
| `download_wid()` | Download data; returns a `wid_df` |
| `wid_decode()` | Parse a variable code string into components |
| `wid_encode()` | Build a variable code string from components |
| `wid_validate()` | Validate components; stops on failure |
| `wid_is_valid()` | Non-throwing validation; returns `TRUE`/`FALSE` |
| `wid_search()` | Keyword/regex search across reference tables |
| `wid_tidy()` | Coerce types; append decoded and country name columns |
| `wid_convert()` | Currency conversion (`"lcu"`, `"usd"`, `"eur"`, `"gbp"`, `"ppp"`, `"yppp"`) |
| `wid_metadata()` | Retrieve source and methodological documentation |
| `wid_gini()` | Gini coefficient from a share (`s`) series |
| `wid_top_share()` | Top fractile income/wealth share |
| `wid_percentile_ratio()` | Percentile threshold ratio (default P90/P10) |
| `wid_plot_timeseries()` | Time-series line chart; returns a `ggplot` object |
| `wid_plot_compare()` | Cross-country bar/point chart; returns a `ggplot` object |
| `wid_plot_lorenz()` | Lorenz curve; returns a `ggplot` object |
| `wid_query()` | Construct a reusable query object |
| `wid_filter()` | Update fields of a `wid_query` |
| `wid_fetch()` | Execute a `wid_query`; returns a `wid_df` |
| `wid_cache()` | Low-level cache access (`"get"`, `"set"`, `"list"`, `"clear"`) |
| `wid_cache_list()` | List cached query keys |
| `wid_cache_clear()` | Remove all cached responses |
| `wid_set_key()` | Set the WID API key |
| `print.wid_df` | S3 print method for `wid_df` objects |
| `print.wid_query` | S3 print method for `wid_query` objects |

| Dataset | Contents |
|---------|----------|
| `wid_series_types` | `r nrow(wid_series_types)` series type codes |
| `wid_concepts` | `r nrow(wid_concepts)` concept codes |
| `wid_ages` | Age group codes |
| `wid_pop_types` | Population unit codes |
| `wid_countries` | `r nrow(wid_countries)` country and region codes |
| `wid_percentiles` | `r nrow(wid_percentiles)` percentile group codes |

---

**Disclaimer:** `widr` is an independent implementation unaffiliated with the World Inequality Lab (WIL) or the Paris School of Economics. Data are sourced from WID.world, maintained by WIL. Codes reference: [wid.world/codes-dictionary](https://wid.world/codes-dictionary/).

Full getting-started guide: `vignette("widr")`
