Persistence to last grade of primary, total (% of cohort)

Source: worldbank.org, 03.09.2025

Year: 2020

Flag Country Value Value change, % Rank
Aruba Aruba 85.5 -3.04% 76
Albania Albania 91.9 +2.8% 70
Andorra Andorra 66.1 -1.89% 89
Argentina Argentina 96.5 +2.22% 52
Armenia Armenia 99.6 +0.257% 12
Austria Austria 99.7 +0.0944% 9
Azerbaijan Azerbaijan 94.2 -1.24% 66
Benin Benin 54.1 +39.6% 94
Burkina Faso Burkina Faso 62.1 +14% 90
Bulgaria Bulgaria 97.5 +1.78% 43
Bosnia & Herzegovina Bosnia & Herzegovina 95 +1.51% 64
Belarus Belarus 98.3 +0.00728% 37
Belize Belize 96.3 +6.78% 53
Barbados Barbados 94.8 +1.55% 65
Switzerland Switzerland 99.4 -0.179% 18
Chile Chile 99.6 +0.367% 14
China China 96.8 -0.0624% 49
Côte d’Ivoire Côte d’Ivoire 70.1 -10.2% 87
Congo - Kinshasa Congo - Kinshasa 73.3 +62% 84
Colombia Colombia 97.3 +1.81% 47
Cape Verde Cape Verde 96.8 +9.06% 50
Costa Rica Costa Rica 97.4 +4.34% 45
Cuba Cuba 97.3 +1.36% 48
Cyprus Cyprus 98.1 +0.863% 39
Czechia Czechia 99.5 -0.0781% 16
Djibouti Djibouti 89.5 +1.36% 71
Denmark Denmark 99.7 +0.0095% 10
Dominican Republic Dominican Republic 56.2 -34% 93
Algeria Algeria 89 -2.83% 72
Ecuador Ecuador 98.5 +2.11% 32
Egypt Egypt 99.8 +0.111% 5
Spain Spain 99.9 +0.105% 1
Estonia Estonia 99.7 -0.0532% 8
Finland Finland 99.8 +0.266% 4
United Kingdom United Kingdom 99.3 -0.522% 21
Georgia Georgia 99.2 +0.903% 25
Gambia Gambia 78.2 -1.86% 82
Greece Greece 99.5 +0.00624% 17
Guatemala Guatemala 93.7 +22.5% 68
Honduras Honduras 72.7 -5.26% 85
Croatia Croatia 98.5 +0.0211% 34
Hungary Hungary 98.9 +0.0998% 28
India India 99.6 +1.15% 11
Israel Israel 98.8 -0.189% 29
Italy Italy 99.2 -0.705% 26
Jordan Jordan 97.4 +4.02% 44
Kyrgyzstan Kyrgyzstan 97.7 -0.0273% 42
Kiribati Kiribati 83 +5.14% 80
South Korea South Korea 99.7 +0.551% 6
Kuwait Kuwait 85.7 -8.74% 75
Lebanon Lebanon 86.1 +1.52% 74
Liechtenstein Liechtenstein 96.3 +6.81% 54
Lithuania Lithuania 99.5 +0.576% 15
Luxembourg Luxembourg 78.4 -5.54% 81
Latvia Latvia 98.5 +1.59% 33
Macao SAR China Macao SAR China 99.2 +0.149% 24
Morocco Morocco 92 -3.24% 69
Monaco Monaco 93.8 +14.6% 67
Moldova Moldova 95.7 +2.72% 58
Mexico Mexico 97.9 +1.47% 40
Marshall Islands Marshall Islands 83.7 +14.1% 79
North Macedonia North Macedonia 95 +0.38% 63
Malta Malta 96 -2.07% 56
Montenegro Montenegro 98.4 -0.631% 35
Mauritius Mauritius 95.6 +0.156% 59
Malaysia Malaysia 97.7 +0.711% 41
Norway Norway 99.2 +0.0833% 23
Oman Oman 96.5 -2.72% 51
Peru Peru 95.5 +2.54% 61
Portugal Portugal 99.3 +0.246% 20
Palestinian Territories Palestinian Territories 98.7 -0.339% 31
Qatar Qatar 84.8 -10% 77
Romania Romania 95.8 +0.685% 57
Senegal Senegal 61.5 -11.4% 91
Singapore Singapore 99.7 +0.134% 7
El Salvador El Salvador 84.6 +2.96% 78
San Marino San Marino 96.2 -1.78% 55
Serbia Serbia 98.3 +0.808% 36
Suriname Suriname 70.1 -20% 86
Slovakia Slovakia 99.6 +0.379% 13
Slovenia Slovenia 99.4 -0.198% 19
Sweden Sweden 99.8 +0.111% 3
Seychelles Seychelles 95 -0.513% 62
Syria Syria 68.4 -26.6% 88
Togo Togo 59.6 +12.8% 92
Turkmenistan Turkmenistan 99.3 22
Tunisia Tunisia 97.3 +3.32% 46
Turkey Turkey 99.8 -0.0297% 2
Ukraine Ukraine 99.1 +0.725% 27
Uruguay Uruguay 98.7 -0.195% 30
United States United States 87.1 -3.81% 73
Uzbekistan Uzbekistan 98.1 -1.63% 38
Vanuatu Vanuatu 77.1 -9.03% 83
South Africa South Africa 95.5 -0.108% 60

                    
# 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 = 'SE.PRM.PRSL.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 <- 'SE.PRM.PRSL.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))