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

Source: worldbank.org, 01.09.2025

Year: 2009

Flag Country Value Value change, % Rank
Angola Angola 36.6 +25.1% 93
Albania Albania 95.1 +2.01% 36
Argentina Argentina 96.7 +2.25% 28
Armenia Armenia 96.3 -1.75% 29
Azerbaijan Azerbaijan 95.4 -4.61% 35
Burundi Burundi 51.8 -7.34% 91
Benin Benin 56.1 -13.4% 87
Burkina Faso Burkina Faso 61.2 -13.6% 83
Bangladesh Bangladesh 61.9 -7.73% 81
Bulgaria Bulgaria 97.6 +3.85% 23
Bahamas Bahamas 91.4 +17.4% 48
Bosnia & Herzegovina Bosnia & Herzegovina 99.1 10
Belize Belize 89.1 -4.5% 53
Bolivia Bolivia 85.2 58
Brunei Brunei 96 -0.365% 32
Bhutan Bhutan 81.5 -3.49% 61
Central African Republic Central African Republic 53.1 +4.32% 89
Cameroon Cameroon 66.8 -2.69% 76
Congo - Kinshasa Congo - Kinshasa 58 -26% 86
Colombia Colombia 84 +2.99% 59
Costa Rica Costa Rica 87.6 -5.68% 54
Cuba Cuba 96.2 +0.673% 30
Czechia Czechia 98.5 -0.883% 14
Germany Germany 95.7 +0.577% 33
Dominica Dominica 85.8 -3.94% 57
Denmark Denmark 98.6 -0.812% 11
Algeria Algeria 93.2 +1.98% 46
Ecuador Ecuador 91.2 -6.23% 49
Egypt Egypt 95.6 +3.69% 34
Eritrea Eritrea 70.9 -4.29% 73
Estonia Estonia 97.4 -0.807% 25
Ethiopia Ethiopia 35.9 +2.33% 94
Finland Finland 99.5 -0.192% 2
Georgia Georgia 94.1 -0.836% 40
Guinea Guinea 74.3 +9.43% 71
Equatorial Guinea Equatorial Guinea 59.7 +13% 84
Guatemala Guatemala 68.1 -13.6% 75
Hong Kong SAR China Hong Kong SAR China 99.2 -0.284% 7
Honduras Honduras 76.1 +10.6% 69
Croatia Croatia 98.5 -0.118% 13
Hungary Hungary 98.1 +0.608% 20
Iran Iran 92.9 -3.87% 47
Iceland Iceland 97.4 +0.836% 24
Italy Italy 99.5 +0.122% 3
Kazakhstan Kazakhstan 98.4 -0.249% 17
Kyrgyzstan Kyrgyzstan 98 +2.33% 22
St. Kitts & Nevis St. Kitts & Nevis 77.6 +16.1% 67
South Korea South Korea 99.2 +0.331% 6
Kuwait Kuwait 96 -1.92% 31
Laos Laos 70.6 +4.42% 74
St. Lucia St. Lucia 93.5 +3.07% 44
Liechtenstein Liechtenstein 81.3 +1.99% 63
Lesotho Lesotho 61.8 +30.2% 82
Lithuania Lithuania 98.2 -0.0215% 19
Latvia Latvia 94.7 -0.768% 37
Morocco Morocco 90.6 +16.4% 50
Moldova Moldova 93.6 -1.21% 42
Madagascar Madagascar 33.8 -30.2% 96
Mexico Mexico 93.2 +0.237% 45
Mali Mali 78.7 -3.09% 66
Myanmar (Burma) Myanmar (Burma) 72.2 +3.1% 72
Mozambique Mozambique 37.1 +0.392% 92
Mauritius Mauritius 98.5 +4.51% 15
Malawi Malawi 52.1 +23.6% 90
Namibia Namibia 81.8 +2.5% 60
Niger Niger 62.7 -9.56% 79
Nigeria Nigeria 62.5 -22.3% 80
Norway Norway 99.3 -0.558% 4
Pakistan Pakistan 63.7 +3.57% 77
Panama Panama 93.7 +9.21% 41
Peru Peru 89.8 +2.52% 52
Poland Poland 99.2 +1.86% 8
Paraguay Paraguay 81.4 +7.02% 62
Romania Romania 97.1 +4.73% 27
Rwanda Rwanda 35 -5.51% 95
Sudan Sudan 78.8 65
Senegal Senegal 58.1 +2.96% 85
El Salvador El Salvador 86 +15.9% 56
Serbia Serbia 98.4 -0.53% 18
Suriname Suriname 75.6 -7.68% 70
Slovakia Slovakia 98.1 +0.501% 21
Slovenia Slovenia 99.1 -0.599% 9
Sweden Sweden 99.3 +0.527% 5
Eswatini Eswatini 81.2 +16.7% 64
Syria Syria 94.3 +1.63% 39
Chad Chad 28.3 -16.2% 97
Togo Togo 54.6 -28.1% 88
Tajikistan Tajikistan 98.6 +0.359% 12
Timor-Leste Timor-Leste 63.3 -10.6% 78
Trinidad & Tobago Trinidad & Tobago 86.9 -6.87% 55
Tunisia Tunisia 94.6 +0.679% 38
Turkey Turkey 98.5 +8.6% 16
Tanzania Tanzania 76.4 +7.41% 68
Ukraine Ukraine 97.4 -0.148% 26
Uruguay Uruguay 93.5 -0.00281% 43
Uzbekistan Uzbekistan 99.7 +1.87% 1
Venezuela Venezuela 90.1 +1.13% 51

                    
# 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.MA.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.MA.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))