Adjusted savings: net national savings (% of GNI)

Source: worldbank.org, 03.09.2025

Year: 2021

Flag Country Value Value change, % Rank
Aruba Aruba 3.21 -149% 101
Angola Angola 35.5 +43.9% 4
Albania Albania 2.54 -176% 106
Argentina Argentina 10.3 +85% 58
Armenia Armenia 4.03 +19.9% 96
Australia Australia 8.75 +35.4% 69
Austria Austria 8.56 -2.48% 70
Azerbaijan Azerbaijan 24.9 +62.6% 13
Belgium Belgium 6.89 +31.4% 77
Bangladesh Bangladesh 33 -4.82% 6
Bulgaria Bulgaria 7.39 +14.4% 74
Bahamas Bahamas 2.17 -63% 109
Bosnia & Herzegovina Bosnia & Herzegovina 5.83 +255% 85
Belarus Belarus 13.5 +14.4% 47
Belize Belize 7.47 -29.3% 73
Bermuda Bermuda 36.6 +10.2% 3
Bolivia Bolivia 1.73 +134% 112
Brazil Brazil -1.02 -78.4% 121
Brunei Brunei 38.4 -1.13% 1
Bhutan Bhutan 12.7 -27.8% 49
Botswana Botswana 2.61 +27.8% 105
Canada Canada 6.59 +472% 80
Switzerland Switzerland 12 +55.6% 53
Chile Chile 1.72 -49.9% 113
China China 18.8 +7.32% 29
Cameroon Cameroon 3.04 +47.6% 102
Congo - Kinshasa Congo - Kinshasa 21.1 +14.5% 19
Colombia Colombia 2.85 -24.7% 103
Comoros Comoros 6.81 +145% 78
Cape Verde Cape Verde 21.2 -8.54% 18
Costa Rica Costa Rica 10.8 +18.2% 56
Cyprus Cyprus -2.11 -27.2% 123
Czechia Czechia 7.16 +15.3% 75
Germany Germany 10.7 +13.9% 57
Denmark Denmark 14.8 +15.4% 41
Dominican Republic Dominican Republic 22.2 +26.8% 16
Algeria Algeria 29 +30% 9
Ecuador Ecuador 6.36 +3.53% 82
Egypt Egypt 1.82 -66% 111
Spain Spain 4.72 +32.6% 90
Estonia Estonia 13.7 +22.4% 45
Ethiopia Ethiopia 17.8 -7.95% 31
Finland Finland 6.16 +10.2% 84
France France 4.9 +202% 89
United Kingdom United Kingdom 0.801 -137% 116
Georgia Georgia -2.92 +154% 125
Ghana Ghana 12.3 -34.2% 51
Guinea Guinea -10.3 +25.6% 132
Gambia Gambia 20.5 +99.7% 21
Greece Greece -3.95 -55.4% 128
Guatemala Guatemala 7.91 +16.2% 71
Hong Kong SAR China Hong Kong SAR China 9.14 +45.7% 66
Honduras Honduras 15.7 -16.8% 38
Croatia Croatia 6.24 +34.5% 83
Haiti Haiti 9.4 -31.3% 62
Hungary Hungary 9.27 +2.52% 65
Indonesia Indonesia 13.7 +40% 46
India India 18.6 +8.46% 30
Ireland Ireland 16.7 +56.1% 34
Iraq Iraq 20.4 +104% 23
Iceland Iceland -1.2 -224% 122
Israel Israel 14.5 +3.46% 42
Italy Italy 4.59 +94.8% 91
Jamaica Jamaica 28.7 +37.6% 10
Jordan Jordan 4.09 -20.9% 95
Japan Japan 1.88 -37.7% 110
Kazakhstan Kazakhstan 17 +0.045% 33
Kenya Kenya 5.53 +62% 87
Kyrgyzstan Kyrgyzstan 7.15 -61% 76
Cambodia Cambodia 19.4 +6.26% 25
South Korea South Korea 15.5 +0.289% 39
Lebanon Lebanon -25.1 +35% 134
Lithuania Lithuania 9.13 +7.71% 67
Luxembourg Luxembourg 16.2 +45.9% 36
Latvia Latvia 0.262 -88.7% 117
Macao SAR China Macao SAR China 22.8 -14.8% 15
Morocco Morocco 19.1 +6.72% 27
Moldova Moldova 4.2 -2.24% 94
Madagascar Madagascar 2.72 +44.1% 104
Maldives Maldives 21.1 -875% 20
Mexico Mexico 3.6 -33.1% 97
North Macedonia North Macedonia 13.9 +23.2% 43
Malta Malta 16.3 +41.4% 35
Montenegro Montenegro 5.07 -172% 88
Mongolia Mongolia 10.3 +121% 59
Mozambique Mozambique -8.02 +44% 131
Mauritania Mauritania 31.4 +7.98% 7
Mauritius Mauritius -3.23 -51% 126
Malaysia Malaysia 5.55 +60.1% 86
Namibia Namibia -5.45 -194% 130
Nigeria Nigeria 23.7 +27.8% 14
Nicaragua Nicaragua 12.4 -19.7% 50
Netherlands Netherlands 11.8 +21.2% 54
Norway Norway 21.5 +106% 17
Nepal Nepal 25.7 -0.329% 12
New Zealand New Zealand 3.56 -27.5% 99
Oman Oman 11.6 +149% 55
Pakistan Pakistan 10.1 -3.56% 60
Panama Panama 18.9 +13% 28
Peru Peru 12 +13% 52
Philippines Philippines 9.4 -31% 63
Poland Poland 8.78 -0.816% 68
Portugal Portugal -0.485 -76.4% 119
Paraguay Paraguay 17.1 +1.46% 32
Palestinian Territories Palestinian Territories 6.77 +526% 79
Qatar Qatar 34.2 +39.3% 5
Romania Romania 3.57 -14.9% 98
Russia Russia 15.9 +24.3% 37
Rwanda Rwanda 2.48 -1,601% 107
Sudan Sudan -0.0157 -100% 118
Singapore Singapore 29.5 +22.4% 8
El Salvador El Salvador 4.33 -44% 93
Serbia Serbia 6.46 +4.01% 81
Slovakia Slovakia 1.59 -23.2% 115
Slovenia Slovenia 7.77 -5.31% 72
Sweden Sweden 13.5 +4.27% 48
Eswatini Eswatini 2.39 -304% 108
Seychelles Seychelles -3.82 -28.8% 127
Thailand Thailand 9.35 +1.79% 64
Timor-Leste Timor-Leste -23.6 -878% 133
Tonga Tonga -4.42 -134% 129
Tunisia Tunisia -2.72 -54.2% 124
Turkey Turkey 15.4 +31.7% 40
Uganda Uganda 4.38 -41.9% 92
Ukraine Ukraine -0.721 -41.5% 120
Uruguay Uruguay 9.86 -0.529% 61
United States United States 1.64 -30.9% 114
Uzbekistan Uzbekistan 19.4 -3.23% 26
Vietnam Vietnam 20.2 -1.22% 24
Vanuatu Vanuatu 36.7 -7.64% 2
Samoa Samoa 20.4 -21.1% 22
Kosovo Kosovo 13.8 +2.73% 44
South Africa South Africa 3.51 -500% 100
Zambia Zambia 27.2 -0.0947% 11

                    
# Install missing packages
import sys
import subprocess

def install(package):
subprocess.check_call([sys.executable, "-m", "pip", "install", package])

# Required packages
for package in ['wbdata', 'country_converter']:
try:
__import__(package)
except ImportError:
install(package)

# Import libraries
import wbdata
import country_converter as coco
from datetime import datetime

# Define World Bank indicator code
dataset_code = 'NY.ADJ.NNAT.GN.ZS'

# Download data from World Bank API
data = wbdata.get_dataframe({dataset_code: 'value'},
date=(datetime(1960, 1, 1), datetime.today()),
parse_dates=True,
keep_levels=True).reset_index()

# Extract year
data['year'] = data['date'].dt.year

# Convert country names to ISO codes using country_converter
cc = coco.CountryConverter()
data['iso2c'] = cc.convert(names=data['country'], to='ISO2', not_found=None)
data['iso3c'] = cc.convert(names=data['country'], to='ISO3', not_found=None)

# Filter out rows where ISO codes could not be matched — likely not real countries
data = data[data['iso2c'].notna() & data['iso3c'].notna()]

# Sort for calculation
data = data.sort_values(['iso3c', 'year'])

# Calculate YoY absolute and percent change
data['value_change'] = data.groupby('iso3c')['value'].diff()
data['value_change_percent'] = data.groupby('iso3c')['value'].pct_change() * 100

# Calculate ranks (higher GDP per capita = better rank)
data['rank'] = data.groupby('year')['value'].rank(ascending=False, method='dense')

# Calculate rank change from previous year
data['rank_change'] = data.groupby('iso3c')['rank'].diff()

# Select desired columns
final_df = data[['country', 'iso2c', 'iso3c', 'year', 'value',
'value_change', 'value_change_percent', 'rank', 'rank_change']].copy()

# Optional: Add labels as metadata (could be useful for export or UI)
column_labels = {
'country': 'Country name',
'iso2c': 'ISO 2-letter country code',
'iso3c': 'ISO 3-letter country code',
'year': 'Year',
'value': 'GDP per capita (current US$)',
'value_change': 'Year-over-Year change in value',
'value_change_percent': 'Year-over-Year percent change in value',
'rank': 'Country rank by GDP per capita (higher = richer)',
'rank_change': 'Change in rank from previous year'
}

# Display first few rows
print(final_df.head(10))

# Optional: Save to CSV
#final_df.to_csv("gdp_per_capita_cleaned.csv", index=False)
                    
                
                    
# Check and install required packages
required_packages <- c("WDI", "countrycode", "dplyr")

for (pkg in required_packages) {
  if (!requireNamespace(pkg, quietly = TRUE)) {
    install.packages(pkg)
  }
}

# Load the necessary libraries
library(WDI)
library(dplyr)
library(countrycode)

# Define the dataset code (World Bank indicator code)
dataset_code <- 'NY.ADJ.NNAT.GN.ZS'

# Download data using WDI package
dat <- WDI(indicator = dataset_code)

# Filter only countries using 'is_country' from countrycode
# This uses iso2c to identify whether the entry is a recognized country
dat <- dat %>%
  filter(countrycode(iso2c, origin = 'iso2c', destination = 'country.name', warn = FALSE) %in%
           countrycode::codelist$country.name.en)

# Ensure dataset is ordered by country and year
dat <- dat %>%
  arrange(iso3c, year)

# Rename the dataset_code column to "value" for easier manipulation
dat <- dat %>%
  rename(value = !!dataset_code)

# Calculate year-over-year (YoY) change and percentage change
dat <- dat %>%
  group_by(iso3c) %>%
  mutate(
    value_change = value - lag(value),                              # Absolute change from previous year
    value_change_percent = 100 * (value - lag(value)) / lag(value) # Percent change from previous year
  ) %>%
  ungroup()

# Calculate rank by year (higher value => higher rank)
dat <- dat %>%
  group_by(year) %>%
  mutate(rank = dense_rank(desc(value))) %>% # Rank countries by descending value
  ungroup()

# Calculate rank change (positive = moved up, negative = moved down)
dat <- dat %>%
  group_by(iso3c) %>%
  mutate(rank_change = rank - lag(rank)) %>% # Change in rank compared to previous year
  ungroup()

# Select and reorder final columns
final_data <- dat %>%
  select(
    country,
    iso2c,
    iso3c,
    year,
    value,
    value_change,
    value_change_percent,
    rank,
    rank_change
  )

# Add labels (variable descriptions)
attr(final_data$country, "label") <- "Country name"
attr(final_data$iso2c, "label") <- "ISO 2-letter country code"
attr(final_data$iso3c, "label") <- "ISO 3-letter country code"
attr(final_data$year, "label") <- "Year"
attr(final_data$value, "label") <- "GDP per capita (current US$)"
attr(final_data$value_change, "label") <- "Year-over-Year change in value"
attr(final_data$value_change_percent, "label") <- "Year-over-Year percent change in value"
attr(final_data$rank, "label") <- "Country rank by GDP per capita (higher = richer)"
attr(final_data$rank_change, "label") <- "Change in rank from previous year"

# Print the first few rows of the final dataset
print(head(final_data, 10))