Gross domestic savings (% of GDP)

Source: worldbank.org, 03.09.2025

Year: 2024

Flag Country Value Value change, % Rank
Angola Angola 38.5 +0.0752% 9
Albania Albania 17.6 -0.826% 84
Argentina Argentina 16.9 -4.51% 87
Armenia Armenia 22.7 +10.9% 56
Australia Australia 26.5 -6.43% 36
Austria Austria 25.3 -7.26% 42
Azerbaijan Azerbaijan 30.2 -6.22% 26
Belgium Belgium 24 -3.03% 51
Benin Benin 32.1 +7.46% 22
Burkina Faso Burkina Faso 20.6 +33.6% 69
Bangladesh Bangladesh 24 -7% 52
Bulgaria Bulgaria 22.7 -4.92% 58
Bahamas Bahamas 22.8 -2.99% 55
Bosnia & Herzegovina Bosnia & Herzegovina 11.4 -9.18% 101
Belarus Belarus 24.2 -14.2% 50
Bermuda Bermuda 43.4 +0.5% 7
Brazil Brazil 17.4 -3.47% 85
Brunei Brunei 48.5 -2.17% 5
Botswana Botswana 22.6 -18.8% 59
Central African Republic Central African Republic -4.32 -24.1% 126
Canada Canada 23 -3.85% 54
Switzerland Switzerland 37.2 -0.329% 13
Chile Chile 26.8 +10.6% 35
Côte d’Ivoire Côte d’Ivoire 25 +10.7% 45
Cameroon Cameroon 15 -3.61% 94
Congo - Kinshasa Congo - Kinshasa 29.2 -0.238% 28
Congo - Brazzaville Congo - Brazzaville 39.2 -8.36% 8
Colombia Colombia 12.1 +3.67% 100
Comoros Comoros -12.8 -3.23% 129
Cape Verde Cape Verde 4.58 +224% 115
Costa Rica Costa Rica 21.4 +3.81% 64
Cyprus Cyprus 22.5 +3.86% 60
Czechia Czechia 32.6 -1.25% 20
Germany Germany 24.9 -3.02% 46
Djibouti Djibouti 8.22 -33% 106
Denmark Denmark 32.4 +4.74% 21
Dominican Republic Dominican Republic 20.8 +0.644% 66
Ecuador Ecuador 21.8 +5.06% 62
Egypt Egypt 6.15 -56.9% 111
Spain Spain 24.8 -0.707% 47
Estonia Estonia 25.7 -0.796% 39
Ethiopia Ethiopia 14.3 -3.18% 96
Finland Finland 22.7 -0.677% 57
France France 21.2 +0.207% 65
Gabon Gabon 54.2 -1.25% 4
United Kingdom United Kingdom 16.9 +3.84% 86
Georgia Georgia 15.2 -7.16% 92
Ghana Ghana 11.1 +22.7% 102
Guinea Guinea 19.2 +20.8% 75
Gambia Gambia 8.35 +24.4% 105
Guinea-Bissau Guinea-Bissau 5.22 +10.6% 114
Equatorial Guinea Equatorial Guinea 18.7 -11.3% 76
Greece Greece 12.8 +6.91% 99
Guatemala Guatemala 1.13 -19.1% 119
Hong Kong SAR China Hong Kong SAR China 19.8 +18.4% 73
Honduras Honduras -1.52 -18.7% 124
Croatia Croatia 20.4 -4.95% 71
Haiti Haiti -5.51 -13.8% 128
Hungary Hungary 29.2 -4.23% 29
Indonesia Indonesia 36.9 -3.28% 14
India India 28.4 -3.86% 32
Ireland Ireland 58.9 -1.14% 1
Iran Iran 36.6 -0.627% 15
Iraq Iraq 38.5 -9.89% 10
Iceland Iceland 25.4 -0.926% 41
Israel Israel 25.9 -10.5% 37
Italy Italy 24.6 +1.18% 48
Kenya Kenya 13 +16.8% 98
Cambodia Cambodia 34.4 +2.41% 17
Libya Libya 30.6 -5.36% 25
Sri Lanka Sri Lanka 24.3 +8.5% 49
Lithuania Lithuania 25.6 -0.952% 40
Luxembourg Luxembourg 47.9 -1.09% 6
Latvia Latvia 18.6 -10.9% 78
Macao SAR China Macao SAR China 58.8 +4.78% 2
Morocco Morocco 20.7 +0.961% 67
Moldova Moldova -4.71 +27.8% 127
Madagascar Madagascar 14.9 +16.5% 95
Mexico Mexico 18.5 -2.77% 79
North Macedonia North Macedonia 15.3 -7.82% 91
Mali Mali 15 +3.76% 93
Malta Malta 36.2 -1.01% 16
Montenegro Montenegro 5.86 -34.6% 112
Mongolia Mongolia 33.9 -20.1% 18
Mozambique Mozambique 13.9 +189% 97
Mauritius Mauritius 16.7 +5.39% 88
Malaysia Malaysia 27.2 -1.36% 34
Namibia Namibia -0.727 -116% 122
Niger Niger 29 +28.3% 31
Nicaragua Nicaragua 7.09 -19.8% 107
Netherlands Netherlands 31.4 +0.819% 24
Norway Norway 37.9 -4.55% 12
Nepal Nepal 6.22 -13.8% 110
Pakistan Pakistan 6.26 -1.87% 109
Peru Peru 25 +10.4% 44
Philippines Philippines 9.35 +0.931% 103
Poland Poland 21.7 -7.45% 63
Puerto Rico Puerto Rico 15.8 +9.01% 90
Portugal Portugal 21.9 +1.27% 61
Paraguay Paraguay 20.4 -6.73% 70
Palestinian Territories Palestinian Territories -16.2 -15.7% 130
Romania Romania 18.2 -13.3% 80
Russia Russia 32.1 -2.15% 23
Rwanda Rwanda 18.1 +96.8% 82
Saudi Arabia Saudi Arabia 33.7 -5.24% 19
Sudan Sudan 2.8 +46.1% 117
Senegal Senegal 17.8 +6.31% 83
Singapore Singapore 57.9 -0.847% 3
Sierra Leone Sierra Leone 6.9 -16.4% 108
El Salvador El Salvador 1.21 -31.6% 118
Somalia Somalia -31.6 +2.49% 131
Serbia Serbia 19.5 -3.87% 74
Slovakia Slovakia 20.3 -4.94% 72
Slovenia Slovenia 27.7 -3.1% 33
Sweden Sweden 29 +0.467% 30
Seychelles Seychelles -0.863 -113% 123
Chad Chad 30 +8.46% 27
Togo Togo 8.58 -8.07% 104
Thailand Thailand 25.1 -3.14% 43
Tunisia Tunisia 5.23 +138% 113
Turkey Turkey 25.8 -6.2% 38
Tanzania Tanzania 37.9 +2.13% 11
Uganda Uganda 23.8 +26.2% 53
Ukraine Ukraine -0.29 -89.8% 121
Uruguay Uruguay 20.7 -1.2% 68
United States United States 18.6 -0.0809% 77
Uzbekistan Uzbekistan 18.1 +6.05% 81
Samoa Samoa 1.06 -118% 120
Kosovo Kosovo 3.38 +3.16% 116
South Africa South Africa 15.9 -2.05% 89
Zimbabwe Zimbabwe -3.99 -146% 125

                    
# 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.GDS.TOTL.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.GDS.TOTL.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))