The NextGen Harmonised Data Gateway
  • Home
  • Variable Database
    • Variable Database
    • Make it Green!
    • Make it Digital!
    • Make it Equal!
    • Make it Healthy!
    • Make it Strong!
  • Harmonisation
    • Harmonisation Toolbox
    • Make it Green!
    • Make it Digital!
    • Make it Equal!
    • Make it Healthy!
    • Make it Strong!
  • Data
  • Training
  • Contact
    • User Support
    • Team

On this page

  • Set-up
  • 1. Prepare Data: ISSP 2000
  • 2. Prepare Data: ISSP 2010
  • 3. Prepare Data: EVS 2008
  • 4. Harmonisation
  • Summary

Earth’s Population Limit

This page guides you through the harmonisation process of the Earth´s Population Limit item.

The item was administered in ISSP 2000, ISSP 2010 and EVS 2008. Before we start harmonising, please download these data sets from the respective repositories. You can find links to the survey repositories on the Make It Green! data documentation page in the section devoted to Earth´s Population Limit. If you click on the single year, the link takes you to the specific data set. We are working with the .sav format. So please make sure to download the datasets in this format.

Set-up

Please download the statistical software R (R Core Team, 2024) and RStudio (RStudio Team, 2023). Then start a project in RStudio by clicking File > New Project and set up a new directory or assign your project to an existing directory (i.e., folder). Within the project directory, create a folder called “data”. Now save the downloaded ISSP 2000, 2010, and EVS 2008 survey data into this “data” folder. Lastly, please download the following packages using the install.packages() function if they have not been before.

install.packages()
packages <- c( "tidyverse", "readxl", "xlsx", "haven", "labelled", "tidyr", "knitr", "kableExtra", "dplyr", "openxlsx")

installed <- packages %in% rownames(installed.packages())
if (any(!installed)) install.packages(packages[!installed])

Every package installed in R must also be loaded. This is what the library-function is for.

library(tidyverse)
library(readxl)
library(openxlsx) # If you have problems installing or loading the xlsx-package, use the openxlsx. 
library(haven)
library(labelled)
library(tidyr)
library(knitr)
library(kableExtra)
library(dplyr)

An important step during the harmonisation process is to prepare the source data sets in a consistent and systematic way. For that, the functions “codebook” (create_codebook_short()) and ”crosswalk table” (create_cwt()) by Kołczyńska (2022) are used. They show the correspondence between source data sets and harmonised data regarding variable names and values. These functions are adopted into our needs and R file containing them can be downloaded here . Please save this file in the R project folder and import it into the R project via source("kolczynska2022_i4ng.R").

How-to

If you cannot download the R-file and if it is opened in a new tab, please open a new file in your R-Studio project under File -> New File -> R Script and copy the text from the kolczynska2022-file into this new file. Make sure that you save this new file in your project folder under the name “kolczynska2022_i4ng.R”.

source("kolczynska2022_i4ng.R")

Now we can name our target variable as “g_ep_popu”. The name is a combination of “g” representing the main topic “green”, the concept “Environmental Problems and Threats” and the variable label “Earth´s Population Limit”.

target_var_hrms <- "g_ep_popu"

Before we can harmonise any data, we need to prepare the source data sets:

1. Prepare Data: ISSP 2000

Six steps must be carried out in the following coding section:

1.1 Import data

issp00 <- haven::read_sav("data/ZA3440_2006-04-12.sav", user_na=TRUE)
Check the source item

Use this output to compare it with your output. Check especially if the labels match.

issp00 %>% count(V17)
# A tibble: 8 × 2
  V17                                n
  <dbl+lbl>                      <int>
1 0 (NA) [NAV]                    1000
2 1 [Strongly Agree]              5021
3 2 [Agree]                      10795
4 3 [Neither Agree nor Disagree]  5081
5 4 [Disagree]                    4520
6 5 [Strongly Disagree]           1258
7 8 (NA) [Cant Choose, DK]        3001
8 9 (NA) [NA, refused]             366

1.2. Create codebook

Not just the substantive variables but also protocol variables need to be selected from this data set. Protocol variables selected for this harmonisation are the source data’s country, weight, and ID variables. In this step, we create a codebook that provides an overview of the selected variables and their naming in the harmonised data.

codebook_issp00 <- create_codebook_short(issp00) %>%
  mutate(survey = "ISSP",
         target_var = ifelse(var_source == "V3", "country_source", NA),
         target_var = ifelse(var_source == "V327", "w2_poststr", target_var),
         target_var = ifelse(grepl("RESPONDENT ID|identi|ID number", var_label_source, perl = TRUE), "caseID_source", target_var),
         target_var = ifelse(grepl("Earth cannot continue support pres. rate", var_label_source), 
                             target_var_hrms, # NAME FOR THE TARGET VARIABLE to be harmonised
                             target_var),
         target_var = gsub(" ", "_", target_var),
         target_var = tolower(target_var))

codebook_issp00 includes the columns called: var_source, var_label_source, survey, target_var. The variable names which will be used in the harmonised data are listed under target_var.

var_source var_label_source survey target_var
V2 Respondent ID number ISSP caseid_source
V3 Country ISSP country_source
V17 Earth cannot continue support pres. rate ISSP g_ep_popu
V327 WEIGHT Weighting factor ISSP w2_poststr

 

1.3. Retrieve names of the chosen source variables

variables <- codebook_issp00 %>% drop_na(target_var) %>% pull(var_source)

The retrieved variables are: V2, V3, V17, V327.

 

1.4. Select a subset of the survey data containing only the chosen variables

issp00_small <- issp00 %>% select(all_of(variables)) %>% mutate(caseid = row_number())

You will see that the following data set is a subset of the ISSP 2000 with the chosen variables for the harmonised data. The first six rows of the dataset are as follows:

V2 V3 V17 V327 caseid
200001103 2 2 1 1
200001105 2 2 1 2
200001307 2 4 1 3
200001309 2 2 1 4
200001402 2 4 1 5
200001406 2 2 1 6

 

1.5. Create a crosswalk table for the chosen variables

A crosswalk table provides a connection between the source variable values and the target variable values. First, it provides the variables, their labels, and the possible values. Then, the information is linked with the codebook information of the newly specified target variables. Lastly, target values are defined in a variable called target_value.

Here, weight and ID variables are excluded from the crosswalk table. Original codes for the country variable are preserved. NAs are assigned to missing values.

issp00_cwt <- create_cwt(issp00_small %>% 
  select(all_of(variables))) %>% 
  left_join(codebook_issp00, by=join_by(var_source, var_label_source)) %>% 
  mutate(target_value = NA, 
         target_value = ifelse(!grepl("know|efusal|answer|NA(?!V)|applicable|Cant Choose", value_label_source, perl = TRUE), value_code, target_value),
         value_code = as.character(value_code)
  )
Important

There are decisions about the substantive variable made by taking into account both ISSP and EVS data. The utility of creating a crosswalk table is that the results of these decisions can be seen explicitly by comparing the value_code and target_value columns: Surveys have different definitions for missing values. Because of this difference in missing values, they are recoded into the single missing value “NA”.

Let’s look at the correspondence between g_ep_popu and V17:

issp00_cwt %>% filter(var_source == "V17") %>% 
  kable(row.names = FALSE) %>%
  kable_styling(full_width = FALSE, bootstrap_options = c("striped", "hover"))
var_source var_label_source npos value_n value_label_source value_code survey target_var target_value
V17 Earth cannot continue support pres. rate 1 [0] NAV: 1000 [0] NAV 0 ISSP g_ep_popu 0
V17 Earth cannot continue support pres. rate 2 [1] Strongly Agree: 5021 [1] Strongly Agree 1 ISSP g_ep_popu 1
V17 Earth cannot continue support pres. rate 3 [2] Agree: 10795 [2] Agree 2 ISSP g_ep_popu 2
V17 Earth cannot continue support pres. rate 4 [3] Neither Agree nor Disagree: 5081 [3] Neither Agree nor Disagree 3 ISSP g_ep_popu 3
V17 Earth cannot continue support pres. rate 5 [4] Disagree: 4520 [4] Disagree 4 ISSP g_ep_popu 4
V17 Earth cannot continue support pres. rate 6 [5] Strongly Disagree: 1258 [5] Strongly Disagree 5 ISSP g_ep_popu 5
V17 Earth cannot continue support pres. rate 7 [8] Cant Choose, DK: 3001 [8] Cant Choose, DK 8 ISSP g_ep_popu NA
V17 Earth cannot continue support pres. rate 8 [9] NA, refused: 366 [9] NA, refused 9 ISSP g_ep_popu NA
Optional

It might be useful to export the crosswalk table as a spreadsheet since it serves as a reference document that visualises the connection between the source and harmonised data set.

write.xlsx(issp00_cwt, paste("data/",  target_var_hrms, "_cwt_issp00.xlsx", sep = ''))

 

1.6. Recode survey data using the crosswalk table

To be able to merge survey data with the crosswalk table information, we first need to convert the wide data format to a long data format.

issp00_small_long <- issp00_small %>% 
  mutate(across(everything(), as.character)) %>% 
  pivot_longer(cols = c(V17, V3), , #*var_source_hrms
               names_to = "var_source", values_to = "value_source") 

This is how the first six rows of the issp_small_long should look like:

V2 V327 caseid var_source value_source
200001103 1 1 V17 2
200001103 1 1 V3 2
200001105 1 2 V17 2
200001105 1 2 V3 2
200001307 1 3 V17 4
200001307 1 3 V3 2

Now we use left_join() to recode source values according to the crosswalk table, issp00_cwt.

issp00_hrmsd <- issp00_small_long %>%
  left_join(issp00_cwt, by = c("value_source" = "value_code", "var_source")) %>% 
  select(-c(npos, value_n)) %>% 
  mutate(target_value = as.character(target_value)) %>% 
  pivot_wider(
    id_cols = c(V2, V327, caseid, survey),    # Columns to keep as unique identifiers
    names_from = target_var,      # Column that will become the new column names
    values_from = target_value         # Column containing the values for those new columns
  ) %>% pivot_longer(
    cols = all_of(target_var_hrms), 
    names_to = "target_var", values_to = "target_value") %>% 
  rename(caseID_source = V2)

Now, ISSP 2000 data is ready for harmonisation. This is how the first six rows of the issp00_hrmsd should look like:

caseID_source V327 caseid survey country_source target_var target_value
200001103 1 1 ISSP 2 g_ep_popu 2
200001105 1 2 ISSP 2 g_ep_popu 2
200001307 1 3 ISSP 2 g_ep_popu 4
200001309 1 4 ISSP 2 g_ep_popu 2
200001402 1 5 ISSP 2 g_ep_popu 4
200001406 1 6 ISSP 2 g_ep_popu 2
Optional

At this step, the prepared data can be exported as an Rdata file and saved for later re-use.

saveRDS(issp00_hrmsd, paste("data/",  target_var_hrms, "_issp00.rds", sep = ''))

 

2. Prepare Data: ISSP 2010

We will prepare the ISSP 2010 data following the same steps used for ISSP 2000.

 

2.1. Import data

issp10 <- haven::read_sav("data/ZA5500_v3-0-0.sav", user_na=TRUE)
Check the source item

Use this output to compare it with your output. Check especially if the labels match.

issp10 %>% count(v28)
# A tibble: 7 × 2
  v28                                n
  <dbl+lbl>                      <int>
1 1 [Agree strongly]              7954
2 2 [Agree]                      18291
3 3 [Neither agree nor disagree] 10386
4 4 [Disagree]                    7895
5 5 [Disagree strongly]           1586
6 8 (NA) [Can't choose]           3823
7 9 (NA) [No answer]               502

 

2.2. Create codebook

Protocol variables selected for this harmonisation are the source data’s country, weight, and ID variables. Note that there are two weight variables: design and post-stratification weights. Both of them are included.

codebook_issp10 <- create_codebook_short(issp10) %>%
  mutate(survey = "ISSP",
         target_var = ifelse(var_source == "c_alphan", "country_source", NA),
         target_var = ifelse(var_source == "WEIGHT", "w2_poststr", target_var),
         target_var = ifelse(grepl("ID Number", var_label_source), "caseID_source", target_var),
         target_var = ifelse(grepl("Q11c Earth cannot continue to support population growth at its present rate", var_label_source), 
                             target_var_hrms, # NAME FOR THE TARGET VARIABLE to be harmonised
                             target_var),
         target_var = gsub(" ", "_", target_var),
         target_var = tolower(target_var))

The variable names which will be used in the harmonised data are listed under target_var. The same names are used except for the weight variables because there are two weight variables.

var_source var_label_source survey target_var
c_alphan Country Prefix ISO 3166 Code - alphanumeric ISSP country_source
v28 Q11c Earth cannot continue to support population growth at its present rate ISSP g_ep_popu
CASEID ID Number of Respondent ISSP caseid_source
WEIGHT Weighting factor ISSP w2_poststr

 

2.3. Retrieve names of the chosen source variables

variables <- codebook_issp10 %>% drop_na(target_var) %>% pull(var_source)

The retrieved variables are: c_alphan, v28, CASEID, WEIGHT.

 

2.4. Select a subset of the survey data containing only the chosen variables

issp10_small <- issp10 %>% select(all_of(variables)) %>% mutate(caseid = row_number())

You will see that the following data set is a subset of the ISSP 2010 with the chosen variables for the harmonised data. The first six rows of the dataset are as follows:

c_alphan v28 CASEID WEIGHT caseid
AR 4 20100320000002 1 1
AR 3 20100320000004 1 2
AR 4 20100320000006 1 3
AR 8 20100320000008 1 4
AR 2 20100320000014 1 5
AR 4 20100320000016 1 6

 

2.5. Create a crosswalk table for the chosen variables

Similar to what was implemented in step 1.5, weight and ID variables are excluded from the crosswalk table. Only country and the substantive variable are used for creating the crosswalk table. Original codes for the country variable are preserved. For the substantive variable, “NA” is assigned to missing values; the other values are kept identical.

issp10_cwt <- create_cwt(issp10_small %>% 
  select( c_alphan, all_of(variables))) %>% 
  left_join(codebook_issp10, by=join_by(var_source, var_label_source)) %>% 
  mutate(target_value = NA,
         target_value = ifelse(!grepl("know|efusal|answer|NA|applicable|Can't choose|]DK|] DK|Na", value_label_source), #* CHECK
                               value_code, 
                               target_value),
         value_code = as.character(value_code)
  )
Important

Surveys have different definitions for missing values. Because of this difference in missing values, they are recoded into the single missing value “NA”.

Let’s look at the correspondence between g_ep_popu and v28:

issp10_cwt %>% filter(var_source == "v28") %>%
  kable(row.names = FALSE) %>%
  kable_styling(full_width = FALSE, bootstrap_options = c("striped", "hover"))
var_source var_label_source npos value_n value_label_source value_code survey target_var target_value
v28 Q11c Earth cannot continue to support population growth at its present rate 1 [1] Agree strongly: 7954 [1] Agree strongly 1 ISSP g_ep_popu 1
v28 Q11c Earth cannot continue to support population growth at its present rate 2 [2] Agree: 18291 [2] Agree 2 ISSP g_ep_popu 2
v28 Q11c Earth cannot continue to support population growth at its present rate 3 [3] Neither agree nor disagree: 10386 [3] Neither agree nor disagree 3 ISSP g_ep_popu 3
v28 Q11c Earth cannot continue to support population growth at its present rate 4 [4] Disagree: 7895 [4] Disagree 4 ISSP g_ep_popu 4
v28 Q11c Earth cannot continue to support population growth at its present rate 5 [5] Disagree strongly: 1586 [5] Disagree strongly 5 ISSP g_ep_popu 5
v28 Q11c Earth cannot continue to support population growth at its present rate 6 [8] Can't choose: 3823 [8] Can't choose 8 ISSP g_ep_popu NA
v28 Q11c Earth cannot continue to support population growth at its present rate 7 [9] No answer: 502 [9] No answer 9 ISSP g_ep_popu NA
Optional

It might be useful to export the crosswalk table as a spreadsheet since it serves as a reference document that visualises the connection between the source and harmonised data set.

write.xlsx(issp10_cwt, paste("data/",  target_var_hrms, "_cwt_issp10.xlsx", sep = ''))

 

2.6. Recode survey data using the crosswalk table

We first convert the wide data format to a long data format, and then merge survey data with the crosswalk table information.

issp10_small_long <- issp10_small %>%
  mutate(across(everything(), as.character)) %>%
  pivot_longer(cols = c(v28, c_alphan),
               names_to = "var_source", values_to = "value_source")

This is how the first six rows of the issp10_small_long should look like:

CASEID WEIGHT caseid var_source value_source
20100320000002 1 1 v28 4
20100320000002 1 1 c_alphan AR
20100320000004 1 2 v28 3
20100320000004 1 2 c_alphan AR
20100320000006 1 3 v28 4
20100320000006 1 3 c_alphan AR

Now we use left_join() to recode source values according to the crosswalk table, issp10_cwt.

issp10_hrmsd <- issp10_small_long %>%
  left_join(issp10_cwt, by = c("value_source" = "value_code", "var_source")) %>% 
  select(-c(npos, value_n)) %>% 
  mutate(target_value = as.character(target_value)) %>% 
  pivot_wider(
    id_cols = c(CASEID, WEIGHT, caseid, survey),    # Columns to keep as unique identifiers
    names_from = target_var,      # Column that will become the new column names
    values_from = target_value         # Column containing the values for those new columns
  ) %>% pivot_longer(
    cols = all_of(target_var_hrms), 
    names_to = "target_var", values_to = "target_value") %>% 
  rename(caseID_source = CASEID)

ISSP 2010 data is ready for harmonisation. This is how the first six rows of the issp10_hrmsd should look like:

head(issp10_hrmsd) %>%
  kable(row.names = FALSE) %>%
  kable_styling(full_width = FALSE, bootstrap_options = c("striped", "hover"))
caseID_source WEIGHT caseid survey country_source target_var target_value
20100320000002 1 1 ISSP AR g_ep_popu 4
20100320000004 1 2 ISSP AR g_ep_popu 3
20100320000006 1 3 ISSP AR g_ep_popu 4
20100320000008 1 4 ISSP AR g_ep_popu NA
20100320000014 1 5 ISSP AR g_ep_popu 2
20100320000016 1 6 ISSP AR g_ep_popu 4
Optional

At this step, the prepared data can be exported as an Rdata file and saved for later re-use.

saveRDS(issp10_hrmsd, paste("data/",  target_var_hrms, "_issp10.rds", sep = ''))

 

3. Prepare Data: EVS 2008

Similarly, we will prepare the EVS 2008 data following the same steps as above. As expected, ISSP and EVS data have differences, and they are taken into account in implementing these steps.

 

3.1. Import data

evs <- haven::read_sav("data/ZA4800_v5-0-0.sav", user_na=TRUE, encoding = "ISO-8859-1")
Check the source item

Use this output to compare it with your output. Check especially if the labels match.

evs %>% count(v296)
# A tibble: 7 × 2
  v296                        n
  <dbl+lbl>               <int>
1 -5 (NA) [other missing]     1
2 -2 (NA) [no answer]       790
3 -1 (NA) [don't know]    10910
4  1 [agree strongly]      8725
5  2 [agree]              24817
6  3 [disagree]           17143
7  4 [disagree strongly]   3894

 

3.2. Create codebook

Protocol variables selected for this harmonisation are the source data’s country, weight, and ID variables.

codebook_evs <- create_codebook_short(evs) %>%
  mutate(survey = "EVS",
         target_var = ifelse(var_source == "c_abrv", "country_source", NA),
         target_var = ifelse(var_source == "weight_g", "w2_poststr", target_var),
         target_var = ifelse(grepl("unified respondent number", var_label_source, perl = TRUE), "caseID_source", target_var),
         target_var = ifelse(grepl("environment: approaching the limit of people", var_label_source), 
                             target_var_hrms, # NAME FOR THE TARGET VARIABLE to be harmonised
                             target_var),
         target_var = gsub(" ", "_", target_var),
         target_var = tolower(target_var))

The variable names which will be used in the harmonised data are listed under target_var. The same names are used except for the weight variables because there are two weight variables.

var_source var_label_source survey target_var
id_cocas unified respondent number EVS caseid_source
c_abrv country abbreviation EVS country_source
weight_g weight EVS w2_poststr
v296 environment: approaching the limit of people (Q85B) EVS g_ep_popu

 

3.3. Retrieve names of the chosen source variables

variables <- codebook_evs %>% drop_na(target_var) %>% pull(var_source)

The retrieved variables are: id_cocas, c_abrv, weight_g, v296.

 

3.4. Select a subset of the survey data containing only the chosen variables

evs_small <- evs %>% select(all_of(variables)) %>% mutate(caseid = row_number())

You will see that the following data set is a subset of the EVS 2008 with the chosen variables for the harmonised data. The first six rows of the dataset are as follows:

id_cocas c_abrv weight_g v296 caseid
200800800001 AL 0.9623360 3 1
200800800002 AL 0.7617063 3 2
200800800003 AL 0.7617063 3 3
200800800004 AL 1.0642812 -1 4
200800800005 AL 0.9859014 4 5
200800800006 AL 0.7617063 2 6

 

3.5. Create a crosswalk table for the chosen variables

Similar to what was implemented in step 1.5, weight and ID variables are excluded from the crosswalk table. Only country and the substantive variable are used for creating the crosswalk table. Original codes for the country variable are preserved. For the substantive variable, “NA” is assigned to missing values; the other values are kept identical.

evs_cwt <- create_cwt(evs_small %>% select(c_abrv, v296)) %>% 
  left_join(codebook_evs, by=join_by(var_source, var_label_source)) %>% 
  mutate(target_value = NA,
         target_value = ifelse(!grepl("know|efusal|answer|NA|applicable|not asked| missing|]DK|] DK", value_label_source), 
                               value_code, 
                               target_value),
         value_code = as.character(value_code)
  )
Important

Surveys have different definitions for missing values. Because of this difference in missing values, they are recoded into the single missing value “NA”.

Let’s look at the correspondence between g_ep_popu and v296:

evs_cwt %>% filter(var_source == "v296") %>%
  kable(row.names = FALSE) %>%
  kable_styling(full_width = FALSE, bootstrap_options = c("striped", "hover"))
var_source var_label_source npos value_n value_label_source value_code survey target_var target_value
v296 environment: approaching the limit of people (Q85B) 1 [-5] other missing: 1 [-5] other missing -5 EVS g_ep_popu NA
v296 environment: approaching the limit of people (Q85B) 2 [-4] question not asked: 0 [-4] question not asked -4 EVS g_ep_popu NA
v296 environment: approaching the limit of people (Q85B) 3 [-3] not applicable: 0 [-3] not applicable -3 EVS g_ep_popu NA
v296 environment: approaching the limit of people (Q85B) 4 [-2] no answer: 790 [-2] no answer -2 EVS g_ep_popu NA
v296 environment: approaching the limit of people (Q85B) 5 [-1] don't know: 10910 [-1] don't know -1 EVS g_ep_popu NA
v296 environment: approaching the limit of people (Q85B) 6 [1] agree strongly: 8725 [1] agree strongly 1 EVS g_ep_popu 1
v296 environment: approaching the limit of people (Q85B) 7 [2] agree: 24817 [2] agree 2 EVS g_ep_popu 2
v296 environment: approaching the limit of people (Q85B) 8 [3] disagree: 17143 [3] disagree 3 EVS g_ep_popu 3
v296 environment: approaching the limit of people (Q85B) 9 [4] disagree strongly: 3894 [4] disagree strongly 4 EVS g_ep_popu 4
Optional

It might be useful to export the crosswalk table as a spreadsheet since it serves as a reference document that visualises the connection between the source and harmonised data set.

write.xlsx(evs_cwt, paste("data/",  target_var_hrms, "_cwt_evs.xlsx", sep = ''))

 

3.6. Recode survey data using the crosswalk table

We first convert the wide data format to a long data format, and then merge survey data with the crosswalk table information.

evs_small_long <- evs_small %>%
  mutate(across(everything(), as.character)) %>%
  pivot_longer(cols = c(c_abrv, v296),
               names_to = "var_source", values_to = "value_source")

This is how the first six rows of the evs_small_long should look like:

id_cocas weight_g caseid var_source value_source
200800800001 0.962336045594876 1 c_abrv AL
200800800001 0.962336045594876 1 v296 3
200800800002 0.761706287022894 2 c_abrv AL
200800800002 0.761706287022894 2 v296 3
200800800003 0.761706287022894 3 c_abrv AL
200800800003 0.761706287022894 3 v296 3

Now we use left_join() to recode source values according to the crosswalk table, evs_cwt.

evs_hrmsd <- evs_small_long %>%
  left_join(evs_cwt, by = c("value_source" = "value_code", "var_source")) %>% 
  select(-c(npos, value_n)) %>% 
  mutate(target_value = as.character(target_value)) %>% 
  pivot_wider(
    id_cols = c(id_cocas, weight_g, caseid, survey),    # Columns to keep as unique identifiers
    names_from = target_var,      # Column that will become the new column names
    values_from = target_value         # Column containing the values for those new columns
  ) %>% pivot_longer(
    cols = all_of(target_var_hrms), 
    names_to = "target_var", values_to = "target_value") %>% 
  rename(caseID_source = id_cocas)

EVS data is ready for harmonisation. This is how the first six rows of the evs_hrmsd should look like:

head(evs_hrmsd) %>%
  kable(row.names = FALSE) %>%
  kable_styling(full_width = FALSE, bootstrap_options = c("striped", "hover"))
caseID_source weight_g caseid survey country_source target_var target_value
200800800001 0.962336045594876 1 EVS AL g_ep_popu 3
200800800002 0.761706287022894 2 EVS AL g_ep_popu 3
200800800003 0.761706287022894 3 EVS AL g_ep_popu 3
200800800004 1.06428124468104 4 EVS AL g_ep_popu NA
200800800005 0.985901445634828 5 EVS AL g_ep_popu 4
200800800006 0.761706287022894 6 EVS AL g_ep_popu 2
Optional

At this step, the prepared data can be exported as an Rdata file and saved for later re-use.

saveRDS(evs_hrmsd, paste("data/",  target_var_hrms, "_evs.rds", sep = ''))

 

4. Harmonisation

Linear stretch (de Jonge et al., 2014) or identity linking is used to harmonise items. Kolen & Brennan (2014) and Albano (2016) provide extensive information about identity linking as well as other methodological approaches. Interested users are encouraged to consult these sources for further details.

With the following steps, we will create the harmonised Earth´s Population Limit data.

 

4.1. Standardise country names & apply labels

There are functions specifically written to standardise country names and apply labels. Please download the R file containing these functions here . Then save this file in the R project folder and import it into the R project via source("func_recoded_country.R").

How-to

If you cannot download the R-file, please open a new file in your R-Studio project under File -> New File -> R Script and copy the text from the func_recoded_country-file into this new file. Make sure that you save this new file in your project folder under the name “func_recoded_country.R”.

source("func_recoded_country.R")

Now we also need to specify the country labels for the ISSP 2000 data.

country_labels <- c(
  "10" = "IE",
  "11" = "NL",
  "12" = "NO",
  "13" = "SE",
  "14" = "CZ",
  "15" = "SI",
  "17" = "BG",
  "18" = "RUS",
  "19" = "NZ",
  "2" = "DE_W",
  "20" = "CA",
  "21" = "PH",
  "22" = "IL",
  "24" = "JP",
  "25" = "ES",
  "26" = "LV",
  "3" = "DE_E",
  "30" = "PT",
  "31" = "CL",
  "32" = "DK",
  "33" = "CH",
  "37" = "FI",
  "38" = "MX",
  "4" = "GB",
  "5" = "NIRL",
  "6" = "US",
  "7" = "AT"
)

issp00$V3 <- as.character(issp00$V3) # country needs to be a character before mapping
issp00$V3 <- country_labels[issp00$V3]
issp00_1 <- issp00_hrmsd %>% 
  recoded_country("country_source") %>%
  country_new_labels("country_new") %>%
  func_country_sample("country_source") %>%
  country_source_recoded_labels("country_source_recoded") 

issp10_1 <- issp10_hrmsd %>% 
  recoded_country("country_source") %>%
  country_new_labels("country_new") %>%
  func_country_sample("country_source") %>%
  country_source_recoded_labels("country_source_recoded")

evs_1 <- evs_hrmsd %>% 
  recoded_country("country_source") %>%
  country_new_labels("country_new") %>%
  func_country_sample("country_source") %>%
  country_source_recoded_labels("country_source_recoded")
Check

You can run the following code if you want to check the country variable:

table(evs_hrmsd$country_source, evs_1$country_new)

 

4.2. Weights

For details on decisions and procedures for including weight variables, please see the Make It Green! data documentation page, section Weight Variables.

evs_2 <- evs_1 %>% mutate(weight_g = ifelse(weight_g == 0,1,weight_g))
evs_fnl <- evs_2 %>% mutate(w1_design = weight_g,
                            w2_poststr = weight_g, 
                            w3_combined = as.numeric(w2_poststr))


issp00_2 <- issp00_1 %>% mutate(V327 = ifelse(V327 == 0,1,V327))
issp00_fnl <- issp00_2 %>% mutate(w1_design = V327,
                              w2_poststr = V327, 
                              w3_combined = as.numeric(w2_poststr))

issp10_fnl <- issp10_1 %>% mutate(w1_design = WEIGHT,
                            w2_poststr = WEIGHT, 
                            w3_combined = as.numeric(w2_poststr))

 

4.3. Import additional information about the source data sets

This file, including additional information, can be downloaded here . Please save it into the “data” folder you generated previously.

add_data <- read_excel("data/from_doi_links_green.xlsx") %>% select(-studyno_source, -wave)

 

4.4. Combine all data

commons <- c("caseID_source", "caseid", "survey",
             "target_var","target_value","year", "country_new", "country_source_recoded",
             "w1_design", "w2_poststr", "w3_combined")

evs_fnl$year <- "2008"
issp00_fnl$year <- "2000"
issp10_fnl$year <- "2010"

all_comb <- bind_rows(evs_fnl[, commons],
                      issp00_fnl[, commons],
                      issp10_fnl[, commons]) %>% 
  left_join(add_data, by = c("target_var", "survey", "year")) %>% 
  mutate(
    ## variables To Be Added
    studyno_I4NG = NA,
    version_I4NG = NA,
    doi_I4NG = NA,
    caseID_I4NG = paste(survey, year, country_new, caseid, sep = ''),
    #country_year
    country_year = paste(country_new, year, sep = '_'), 
    # caseID = NA,
    caseID = row_number(),
    
    # code the lengths of response scales in each project
    npoints = case_when( survey == "EVS" ~ 4, survey == "ISSP" ~ 5, TRUE ~ NA_real_ )
  ) %>% 
  # Rename to avoid SPSS duplicate name error
  rename(caseid_sw = caseid, country_I4NG = country_new) 
Check

Let’s check the data set:

head(all_comb) %>%
  kable(row.names = FALSE) %>%
  kable_styling(full_width = FALSE, bootstrap_options = c("striped", "hover"))
caseID_source caseid_sw survey target_var target_value year country_I4NG country_source_recoded w1_design w2_poststr w3_combined title_source doi_source studyno_I4NG version_I4NG doi_I4NG caseID_I4NG country_year caseID npoints
200800800001 1 EVS g_ep_popu 3 2008 AL AL 0.962336045594876 0.962336045594876 0.9623360 Integrated Dataset version 3.0.0 https://doi.org/10.4232/1.13841 NA NA NA EVS2008AL1 AL_2008 1 4
200800800002 2 EVS g_ep_popu 3 2008 AL AL 0.761706287022894 0.761706287022894 0.7617063 Integrated Dataset version 3.0.0 https://doi.org/10.4232/1.13841 NA NA NA EVS2008AL2 AL_2008 2 4
200800800003 3 EVS g_ep_popu 3 2008 AL AL 0.761706287022894 0.761706287022894 0.7617063 Integrated Dataset version 3.0.0 https://doi.org/10.4232/1.13841 NA NA NA EVS2008AL3 AL_2008 3 4
200800800004 4 EVS g_ep_popu NA 2008 AL AL 1.06428124468104 1.06428124468104 1.0642812 Integrated Dataset version 3.0.0 https://doi.org/10.4232/1.13841 NA NA NA EVS2008AL4 AL_2008 4 4
200800800005 5 EVS g_ep_popu 4 2008 AL AL 0.985901445634828 0.985901445634828 0.9859014 Integrated Dataset version 3.0.0 https://doi.org/10.4232/1.13841 NA NA NA EVS2008AL5 AL_2008 5 4
200800800006 6 EVS g_ep_popu 2 2008 AL AL 0.761706287022894 0.761706287022894 0.7617063 Integrated Dataset version 3.0.0 https://doi.org/10.4232/1.13841 NA NA NA EVS2008AL6 AL_2008 6 4
distinct(all_comb, target_var, survey, year)
# A tibble: 3 × 3
  target_var survey year 
  <chr>      <chr>  <chr>
1 g_ep_popu  EVS    2008 
2 g_ep_popu  ISSP   2000 
3 g_ep_popu  ISSP   2010 

 

4.5. Find equivalents of the response categories

transformation <- function(x, x_min, x_max, y_min, y_max){
  
  # x: source scale
  # y: target scale
  
  y = ((x - x_min)/(x_max - x_min))*(y_max-y_min) + y_min
  
  return(y)
}

# source scale
scale_source <- c(1:4)

# Transform the 4-point source scale to the 5-point target scale
scale_transf <- transformation(x = scale_source, x_min = 1, x_max = 4, y_min = 1, y_max = 5)

Equivalents of 1, 2, 3, 4 on the target scale are 1, 2.33, 3.67, 5.

 

4.6. Apply transformation

all_hrmsd <- all_comb %>%
  mutate(value_hrmsd = case_when(survey == "ISSP" & year== 2000 & target_value == "0" ~ "-999",
                                 !(npoints == 5) ~ plyr::mapvalues(target_value,
                                                                   scale_source, 
                                                                   scale_transf),
                                 TRUE ~ target_value)) %>%
  rename(var_hrmsd = target_var) %>% 
  select(-var_hrmsd, -value_hrmsd, var_hrmsd, value_hrmsd, -caseID, caseID, -ends_with("_source"), ends_with("_source"), 
         -target_value, -npoints)%>% 
  pivot_wider(id_cols = c(doi_source, title_source, caseID_source, caseid_sw, survey, country_I4NG, country_source_recoded, year, country_year, 
                w1_design, w2_poststr, w3_combined, caseID_I4NG),    
    names_from = var_hrmsd,      # Column that will become the new column names
    values_from = value_hrmsd # Column containing the values for those new columns
  )

Now the harmonised Earth´s Population Limit data is ready. This is how the first six rows of the all_hrmsd should look like:

doi_source title_source caseID_source caseid_sw survey country_I4NG country_source_recoded year country_year w1_design w2_poststr w3_combined caseID_I4NG g_ep_popu
https://doi.org/10.4232/1.13841 Integrated Dataset version 3.0.0 200800800001 1 EVS AL AL 2008 AL_2008 0.962336045594876 0.962336045594876 0.9623360 EVS2008AL1 3.66666666666667
https://doi.org/10.4232/1.13841 Integrated Dataset version 3.0.0 200800800002 2 EVS AL AL 2008 AL_2008 0.761706287022894 0.761706287022894 0.7617063 EVS2008AL2 3.66666666666667
https://doi.org/10.4232/1.13841 Integrated Dataset version 3.0.0 200800800003 3 EVS AL AL 2008 AL_2008 0.761706287022894 0.761706287022894 0.7617063 EVS2008AL3 3.66666666666667
https://doi.org/10.4232/1.13841 Integrated Dataset version 3.0.0 200800800004 4 EVS AL AL 2008 AL_2008 1.06428124468104 1.06428124468104 1.0642812 EVS2008AL4 NA
https://doi.org/10.4232/1.13841 Integrated Dataset version 3.0.0 200800800005 5 EVS AL AL 2008 AL_2008 0.985901445634828 0.985901445634828 0.9859014 EVS2008AL5 5
https://doi.org/10.4232/1.13841 Integrated Dataset version 3.0.0 200800800006 6 EVS AL AL 2008 AL_2008 0.761706287022894 0.761706287022894 0.7617063 EVS2008AL6 2.33333333333333

 

4.7. Export data

# Rdata
saveRDS(all_hrmsd, paste("data/",  target_var_hrms, "_hrmsd.rds", sep = ''))

# SPSS file
write_sav(all_hrmsd, paste("data/",  target_var_hrms, "_hrmsd.sav", sep = ''))

# STATA file
write_dta(all_hrmsd, paste("data/",  target_var_hrms, "_hrmsd.dta", sep = ''))

# CSV file
write.csv(all_hrmsd, paste("data/",  target_var_hrms, "_hrmsd.csv", sep = ''), row.names = F, quote = T)

 

Summary

Earth´s Population Limit was administered in EVS 2008, ISSP 2000 and ISSP 2010. Our script, first, prepares these three data sets for harmonisation so that they are consistent in format via codebooks and crosswalk tables. Then, the response categories are harmonised using the identity linking/linear stretch approach. After this step, the item is ready for subsequent analysis!

To go back to the Make it Green! Toolbox page, please click here!

Back to top

References

Albano, A. D. (2016). equate: An R package for observed-score linking and equating. Journal of Statistical Software, 74(8), 1–36. https://doi.org/10.18637/jss.v074.i08
de Jonge, T., Veenhoven, R., & Arends, L. (2014). Homogenizing responses to different survey questions on the same topic: Proposal of a scale homogenization method using a reference distribution. Social Indicators Research, 117, 375–300. https://doi.org/10.1007/s11205-013-0335-6
Kołczyńska, M. (2022). Combining multiple survey sources: A reproducible workflow and toolbox for survey data harmonization. Methodological Innovations, 15(1), 62–72. https://doi.org/10.1177/20597991221077923
Kolen, M. J., & Brennan, R. L. (2014). Test equating, scaling, and linking. Springer. https://doi.org/10.1007/978-1-4939-0317-7
R Core Team. (2024). R: A language and environment for statistical computing. R Foundation for Statistical Computing. https://www.R-project.org/
RStudio Team. (2023). RStudio: Integrated development environment for R. https://www.rstudio.com/

© EU Funded Project 101131118 — Infra4NextGen

 

Subject to Terms of Use | Privacy notice | Cookie policy | Built with R and Quarto