// Contact: Davood Qorbani (https://orcid.org/0000-0002-3499-0167) // Version: v6.0 (2024.02.28) // This code needs to be run on the www.microdata.no platform, which uses syntax like the Stata software package. textblock Household level aggregated information --------------------------------------- :::: The population of this research is all households who resided in Norway and were registered as residents as of January 1st from 2005 to 2022, with at least one privately owned passenger vehicle in any year (not necessarily in all years). To find these households in the database, we start by omitting all households without any record of vehicle ownership in the mentioned period — reported as of December 31st each year. Then, we are left with a population that comprises every household in Norway that has owned a passenger vehicle at least once during this period — conditioned to the report date. After this point, various socioeconomic variables are called to the dataset: individual data are aggregated to the household level and then added to the dataset iteratively. Among these households, any household without a record of of battery electric vehicles (BEV) ownership, i.e., those who owned only emitting vehicles, are called gray adopters in this study. Those with at least one record of BEV ownership in this period are called green adopters, even if they have owned gray vehicles. Note: DS stands for Data Set in this script. endblock // Connecting to datastore. #Note that v26 is the latest version at the time of developing this code. require no.ssb.fdb:26 as db // Start point: 2005-01-01 // Cut off point: 2022-12-31 // #Note that not all values are available in the used database after this date. textblock Household Dataset ------------------ ::::: is being created. The household number is the birth number of the contact person in the household. In the register statistics, household members are identified by formal residential address (i.e., address according to the National Population Register). Since 2014, the household has been identified according to the actual residential address. Household number or id, "BEFOLKNING_HUSHNR" (unit = household), indicates persons who live in the same private home. Since the unit of analysis is household, "household number" availability mandates the aggregation of other variables. So, even if data on some other variables may be available, one may consider the years this variable is available. Note: there is another variable, "INNTEKT_HUSHNR", an approximate definition of households that tries to relate household members with the same finance relation. endblock // Making temporary copies of the household dataset: It helps aggregate person (individual) level data into household level data without losing any data in the household dataset. textblock Household Dataset: People living in different households of various sizes in Norway ------------------ - Household size (a.k.a people_in_household_all_ages) is the number of people living in the household (regardless of age), i.e., people with the same household number. - The easiest way to get the household size is using BEFOLKNING_PERS_I_HUSHNR. However, the following procedure is a workaround to include only household contact persons in the dataset. endblock // First, we create a dataset comprising every registered individual in Norway until 2022. Then, we trim it based on the unique ID of household contact persons. create-dataset household_DS_all import db/BEFOLKNING_STATUSKODE 2022-01-01 as population_status_code22 // All registered people in Norway until 2022 are in the dataset now. We can drop unnecessary variables. drop population_status_code22 // In an iterative process, we tag the contact persons in all households... create-dataset household_DS_size05 import db/BEFOLKNING_STATUSKODE 2005-01-01 as population_status_code05 // Keeping those who were residents in Norway in 2005. keep if population_status_code05 == '1' generate resident_person05 = 1 // counting resident persons in 2005 tabulate resident_person05, missing import db/BEFOLKNING_HUSHNR 2005-01-01 as household_id05 clone-dataset household_DS_size05 household_DS_finder clone-dataset household_DS_size05 person_DS_Y05 generate count_people05 = 1 collapse(sum) count_people05, by(household_id05) rename count_people05 household_size05 tabulate household_size05, missing merge household_size05 into household_DS_finder on PERSONID_1 merge household_size05 into household_DS_all on PERSONID_1 delete-dataset household_DS_size05 use household_DS_finder drop resident_person05 drop population_status_code05 //drop if sysmiss(household_size05) // Alternative: //keep if household_size05 >= 0 import db/BEFOLKNING_HUSHNR 2006-01-01 as household_id06, outer_join create-dataset household_DS_size06 use household_DS_size06 import db/BEFOLKNING_STATUSKODE 2006-01-01 as population_status_code06 // Keeping those who were residents in Norway in 2006. keep if population_status_code06 == '1' generate resident_person06 = 1 // counting resident persons in 2006 tabulate resident_person06, missing import db/BEFOLKNING_HUSHNR 2006-01-01 as household_id06 clone-dataset household_DS_size06 person_DS_Y06 generate count_people06 = 1 collapse(sum) count_people06, by(household_id06) rename count_people06 household_size06 //tabulate household_size06, missing merge household_size06 into household_DS_finder on PERSONID_1 merge household_size06 into household_DS_all on PERSONID_1 delete-dataset household_DS_size06 use household_DS_finder //drop if sysmiss(household_size05) & sysmiss(household_size06) import db/BEFOLKNING_HUSHNR 2007-01-01 as household_id07, outer_join create-dataset household_DS_size07 use household_DS_size07 import db/BEFOLKNING_STATUSKODE 2007-01-01 as population_status_code07 // Keeping those who were residents in Norway in 2007. keep if population_status_code07 == '1' generate resident_person07 = 1 // counting resident persons in 2007 tabulate resident_person07, missing import db/BEFOLKNING_HUSHNR 2007-01-01 as household_id07 clone-dataset household_DS_size07 person_DS_Y07 generate count_people07 = 1 collapse(sum) count_people07, by(household_id07) rename count_people07 household_size07 //tabulate household_size07, missing merge household_size07 into household_DS_finder on PERSONID_1 merge household_size07 into household_DS_all on PERSONID_1 delete-dataset household_DS_size07 use household_DS_finder //drop if sysmiss(household_size05) & sysmiss(household_size06) & sysmiss(household_size07) import db/BEFOLKNING_HUSHNR 2008-01-01 as household_id08, outer_join create-dataset household_DS_size08 use household_DS_size08 import db/BEFOLKNING_STATUSKODE 2008-01-01 as population_status_code08 // Keeping those who were residents in Norway in 2008. keep if population_status_code08 == '1' generate resident_person08 = 1 // counting resident persons in 2008 tabulate resident_person08, missing import db/BEFOLKNING_HUSHNR 2008-01-01 as household_id08 clone-dataset household_DS_size08 person_DS_Y08 generate count_people08 = 1 collapse(sum) count_people08, by(household_id08) rename count_people08 household_size08 //tabulate household_size08, missing merge household_size08 into household_DS_finder on PERSONID_1 merge household_size08 into household_DS_all on PERSONID_1 delete-dataset household_DS_size08 use household_DS_finder //drop if sysmiss(household_size05) & sysmiss(household_size06) & sysmiss(household_size07) & sysmiss(household_size08) import db/BEFOLKNING_HUSHNR 2009-01-01 as household_id09, outer_join create-dataset household_DS_size09 use household_DS_size09 import db/BEFOLKNING_STATUSKODE 2009-01-01 as population_status_code09 // Keeping those who were residents in Norway in 2009. keep if population_status_code09 == '1' generate resident_person09 = 1 // counting resident persons in 2009 tabulate resident_person09, missing import db/BEFOLKNING_HUSHNR 2009-01-01 as household_id09 clone-dataset household_DS_size09 person_DS_Y09 generate count_people09 = 1 collapse(sum) count_people09, by(household_id09) rename count_people09 household_size09 //tabulate household_size09, missing merge household_size09 into household_DS_finder on PERSONID_1 merge household_size09 into household_DS_all on PERSONID_1 delete-dataset household_DS_size09 use household_DS_finder import db/BEFOLKNING_HUSHNR 2010-01-01 as household_id10, outer_join create-dataset household_DS_size10 use household_DS_size10 import db/BEFOLKNING_STATUSKODE 2010-01-01 as population_status_code10 // Keeping those who were residents in Norway in 2010. keep if population_status_code10 == '1' generate resident_person10 = 1 // counting resident persons in 2010 tabulate resident_person10, missing import db/BEFOLKNING_HUSHNR 2010-01-01 as household_id10 clone-dataset household_DS_size10 person_DS_Y10 generate count_people10 = 1 collapse(sum) count_people10, by(household_id10) rename count_people10 household_size10 //tabulate household_size10, missing merge household_size10 into household_DS_finder on PERSONID_1 merge household_size10 into household_DS_all on PERSONID_1 delete-dataset household_DS_size10 use household_DS_finder import db/BEFOLKNING_HUSHNR 2011-01-01 as household_id11, outer_join create-dataset household_DS_size11 use household_DS_size11 import db/BEFOLKNING_STATUSKODE 2011-01-01 as population_status_code11 // Keeping those who were residents in Norway in 2011. keep if population_status_code11 == '1' generate resident_person11 = 1 // counting resident persons in 2011 tabulate resident_person11, missing import db/BEFOLKNING_HUSHNR 2011-01-01 as household_id11 clone-dataset household_DS_size11 person_DS_Y11 generate count_people11 = 1 collapse(sum) count_people11, by(household_id11) rename count_people11 household_size11 //tabulate household_size11, missing merge household_size11 into household_DS_finder on PERSONID_1 merge household_size11 into household_DS_all on PERSONID_1 delete-dataset household_DS_size11 use household_DS_finder import db/BEFOLKNING_HUSHNR 2012-01-01 as household_id12, outer_join create-dataset household_DS_size12 use household_DS_size12 import db/BEFOLKNING_STATUSKODE 2012-01-01 as population_status_code12 // Keeping those who were residents in Norway in 2012. keep if population_status_code12 == '1' generate resident_person12 = 1 // counting resident persons in 2012 tabulate resident_person12, missing import db/BEFOLKNING_HUSHNR 2012-01-01 as household_id12 clone-dataset household_DS_size12 person_DS_Y12 generate count_people12 = 1 collapse(sum) count_people12, by(household_id12) rename count_people12 household_size12 //tabulate household_size12, missing merge household_size12 into household_DS_finder on PERSONID_1 merge household_size12 into household_DS_all on PERSONID_1 delete-dataset household_DS_size12 use household_DS_finder import db/BEFOLKNING_HUSHNR 2013-01-01 as household_id13, outer_join create-dataset household_DS_size13 use household_DS_size13 import db/BEFOLKNING_STATUSKODE 2013-01-01 as population_status_code13 // Keeping those who were residents in Norway in 2013. keep if population_status_code13 == '1' generate resident_person13 = 1 // counting resident persons in 2013 tabulate resident_person13, missing import db/BEFOLKNING_HUSHNR 2013-01-01 as household_id13 clone-dataset household_DS_size13 person_DS_Y13 generate count_people13 = 1 collapse(sum) count_people13, by(household_id13) rename count_people13 household_size13 //tabulate household_size13, missing merge household_size13 into household_DS_finder on PERSONID_1 merge household_size13 into household_DS_all on PERSONID_1 delete-dataset household_DS_size13 use household_DS_finder import db/BEFOLKNING_HUSHNR 2014-01-01 as household_id14, outer_join create-dataset household_DS_size14 use household_DS_size14 import db/BEFOLKNING_STATUSKODE 2014-01-01 as population_status_code14 // Keeping those who were residents in Norway in 2014. keep if population_status_code14 == '1' generate resident_person14 = 1 // counting resident persons in 2014 tabulate resident_person14, missing import db/BEFOLKNING_HUSHNR 2014-01-01 as household_id14 clone-dataset household_DS_size14 person_DS_Y14 generate count_people14 = 1 collapse(sum) count_people14, by(household_id14) rename count_people14 household_size14 //tabulate household_size14, missing merge household_size14 into household_DS_finder on PERSONID_1 merge household_size14 into household_DS_all on PERSONID_1 delete-dataset household_DS_size14 use household_DS_finder import db/BEFOLKNING_HUSHNR 2015-01-01 as household_id15, outer_join create-dataset household_DS_size15 use household_DS_size15 import db/BEFOLKNING_STATUSKODE 2015-01-01 as population_status_code15 // Keeping those who were residents in Norway in 2015. keep if population_status_code15 == '1' generate resident_person15 = 1 // counting resident persons in 2015 tabulate resident_person15, missing import db/BEFOLKNING_HUSHNR 2015-01-01 as household_id15 clone-dataset household_DS_size15 person_DS_Y15 generate count_people15 = 1 collapse(sum) count_people15, by(household_id15) rename count_people15 household_size15 //tabulate household_size15, missing merge household_size15 into household_DS_finder on PERSONID_1 merge household_size15 into household_DS_all on PERSONID_1 delete-dataset household_DS_size15 use household_DS_finder import db/BEFOLKNING_HUSHNR 2016-01-01 as household_id16, outer_join create-dataset household_DS_size16 use household_DS_size16 import db/BEFOLKNING_STATUSKODE 2016-01-01 as population_status_code16 // Keeping those who were residents in Norway in 2016. keep if population_status_code16 == '1' generate resident_person16 = 1 // counting resident persons in 2016 tabulate resident_person16, missing import db/BEFOLKNING_HUSHNR 2016-01-01 as household_id16 clone-dataset household_DS_size16 person_DS_Y16 generate count_people16 = 1 collapse(sum) count_people16, by(household_id16) rename count_people16 household_size16 //tabulate household_size16, missing merge household_size16 into household_DS_finder on PERSONID_1 merge household_size16 into household_DS_all on PERSONID_1 delete-dataset household_DS_size16 use household_DS_finder import db/BEFOLKNING_HUSHNR 2017-01-01 as household_id17, outer_join create-dataset household_DS_size17 use household_DS_size17 import db/BEFOLKNING_STATUSKODE 2017-01-01 as population_status_code17 // Keeping those who were residents in Norway in 2017. keep if population_status_code17 == '1' generate resident_person17 = 1 // counting resident persons in 2017 tabulate resident_person17, missing import db/BEFOLKNING_HUSHNR 2017-01-01 as household_id17 clone-dataset household_DS_size17 person_DS_Y17 generate count_people17 = 1 collapse(sum) count_people17, by(household_id17) rename count_people17 household_size17 //tabulate household_size17, missing merge household_size17 into household_DS_finder on PERSONID_1 merge household_size17 into household_DS_all on PERSONID_1 delete-dataset household_DS_size17 use household_DS_finder import db/BEFOLKNING_HUSHNR 2018-01-01 as household_id18, outer_join create-dataset household_DS_size18 use household_DS_size18 import db/BEFOLKNING_STATUSKODE 2018-01-01 as population_status_code18 // Keeping those who were residents in Norway in 2018. keep if population_status_code18 == '1' generate resident_person18 = 1 // counting resident persons in 2018 tabulate resident_person18, missing import db/BEFOLKNING_HUSHNR 2018-01-01 as household_id18 clone-dataset household_DS_size18 person_DS_Y18 generate count_people18 = 1 collapse(sum) count_people18, by(household_id18) rename count_people18 household_size18 //tabulate household_size18, missing merge household_size18 into household_DS_finder on PERSONID_1 merge household_size18 into household_DS_all on PERSONID_1 delete-dataset household_DS_size18 use household_DS_finder import db/BEFOLKNING_HUSHNR 2019-01-01 as household_id19, outer_join create-dataset household_DS_size19 use household_DS_size19 import db/BEFOLKNING_STATUSKODE 2019-01-01 as population_status_code19 // Keeping those who were residents in Norway in 2019. keep if population_status_code19 == '1' generate resident_person19 = 1 // counting resident persons in 2019 tabulate resident_person19, missing import db/BEFOLKNING_HUSHNR 2019-01-01 as household_id19 clone-dataset household_DS_size19 person_DS_Y19 generate count_people19 = 1 collapse(sum) count_people19, by(household_id19) rename count_people19 household_size19 //tabulate household_size19, missing merge household_size19 into household_DS_finder on PERSONID_1 merge household_size19 into household_DS_all on PERSONID_1 delete-dataset household_DS_size19 use household_DS_finder import db/BEFOLKNING_HUSHNR 2020-01-01 as household_id20, outer_join create-dataset household_DS_size20 use household_DS_size20 import db/BEFOLKNING_STATUSKODE 2020-01-01 as population_status_code20 // Keeping those who were residents in Norway in 2020. keep if population_status_code20 == '1' generate resident_person20 = 1 // counting resident persons in 2020 tabulate resident_person20, missing import db/BEFOLKNING_HUSHNR 2020-01-01 as household_id20 clone-dataset household_DS_size20 person_DS_Y20 generate count_people20 = 1 collapse(sum) count_people20, by(household_id20) rename count_people20 household_size20 //tabulate household_size20, missing merge household_size20 into household_DS_finder on PERSONID_1 merge household_size20 into household_DS_all on PERSONID_1 delete-dataset household_DS_size20 use household_DS_finder import db/BEFOLKNING_HUSHNR 2021-01-01 as household_id21, outer_join create-dataset household_DS_size21 use household_DS_size21 import db/BEFOLKNING_STATUSKODE 2021-01-01 as population_status_code21 keep if population_status_code21 == '1' generate resident_person21 = 1 // counting resident persons in 2021 tabulate resident_person21, missing import db/BEFOLKNING_HUSHNR 2021-01-01 as household_id21 clone-dataset household_DS_size21 person_DS_Y21 generate count_people21 = 1 collapse(sum) count_people21, by(household_id21) rename count_people21 household_size21 //tabulate household_size21, missing merge household_size21 into household_DS_finder on PERSONID_1 merge household_size21 into household_DS_all on PERSONID_1 delete-dataset household_DS_size21 use household_DS_finder import db/BEFOLKNING_HUSHNR 2022-01-01 as household_id22, outer_join create-dataset household_DS_size22 use household_DS_size22 import db/BEFOLKNING_STATUSKODE 2022-01-01 as population_status_code22 keep if population_status_code22 == '1' generate resident_person22 = 1 // counting resident persons in 2022 tabulate resident_person22, missing import db/BEFOLKNING_HUSHNR 2022-01-01 as household_id22 clone-dataset household_DS_size22 person_DS_Y22 generate count_people22 = 1 collapse(sum) count_people22, by(household_id22) rename count_people22 household_size22 //tabulate household_size22, missing merge household_size22 into household_DS_finder on PERSONID_1 merge household_size22 into household_DS_all on PERSONID_1 delete-dataset household_DS_size22 // Who will be in this study? use household_DS_finder // Option A: If you want every registered household in Norway from 2005 to 2022, even if they came or left in between, activate the following: drop if sysmiss(household_size05) & sysmiss(household_size06) & sysmiss(household_size07) & sysmiss(household_size08) & sysmiss(household_size09) & sysmiss(household_size10) & sysmiss(household_size11) & sysmiss(household_size12) & sysmiss(household_size13) & sysmiss(household_size14) & sysmiss(household_size15) & sysmiss(household_size16) & sysmiss(household_size17) & sysmiss(household_size18) & sysmiss(household_size19) & sysmiss(household_size20) & sysmiss(household_size21) & sysmiss(household_size22) // Option B: If you want only those registered households who lived all years from 2005 to 2022 in Norway, activate the following: //drop if sysmiss(household_size05) | sysmiss(household_size06) | sysmiss(household_size07) | sysmiss(household_size08) | sysmiss(household_size09) | sysmiss(household_size10) | sysmiss(household_size11) | sysmiss(household_size12) | sysmiss(household_size13) | sysmiss(household_size14) | sysmiss(household_size15) | sysmiss(household_size16) | sysmiss(household_size17) | sysmiss(household_size18) | sysmiss(household_size19) | sysmiss(household_size20) | sysmiss(household_size21) | sysmiss(household_size22) generate household_this_study = 1 use household_DS_finder merge household_this_study into household_DS_all on PERSONID_1 delete-dataset household_DS_finder use household_DS_all // Keeping only the unique number of those household contact persons who were residents in Norway from 2005 to 2022, irrespective of when they were residents in this period. drop if sysmiss(household_this_study) // Now, we have the unique ID of the household contact person from 2005 to 2022. "household_this_study" can be dropped to free up space. drop household_this_study // Drop unnecessary variables from the cloned datasets to speed up the process. use person_DS_Y05 drop population_status_code05 use person_DS_Y06 drop population_status_code06 use person_DS_Y07 drop population_status_code07 use person_DS_Y08 drop population_status_code08 use person_DS_Y09 drop population_status_code09 use person_DS_Y10 drop population_status_code10 use person_DS_Y11 drop population_status_code11 use person_DS_Y12 drop population_status_code12 use person_DS_Y13 drop population_status_code13 use person_DS_Y14 drop population_status_code14 use person_DS_Y15 drop population_status_code15 use person_DS_Y16 drop population_status_code16 use person_DS_Y17 drop population_status_code17 use person_DS_Y18 drop population_status_code18 use person_DS_Y19 drop population_status_code19 use person_DS_Y20 drop population_status_code20 use person_DS_Y21 drop population_status_code21 use person_DS_Y22 drop population_status_code22 // From this step, we call further relevant variables into our main dataset. // An Option: Making a random draw from the population: It speeds up the analysis. //sample 0.10 422323 // Note 1: The first argument retains 10% of the observations in the dataset, randomly drawn, based on the second argument – arbitrary seed value 422323. // Note 2: The first argument specifies how many observations to keep. This can be an integer > 1000 or a proportion (decimal numbers between 0 and 1). The second argument indicates a seed, where one can use positive integers > = 1. Using the same seed and sample size allows the random extract to be the same each time the command is run. If the user wants a new random sample of the same size, they must use a new seed value. textblock Private Registered Vehicles in Norway by Fuel Type ------------------- ::::: Passenger Vehicles: 2005 - 2022. Note 1: There are missing values in the categories, but the total is the same as the graph on "fuel_type". Note 2: Assigning the fuel types to categories (approach Gray vs. Green) is as follows, - Green: Electric (05). - Gray: Gasoline (Petrol) (01), Diesel (02), Paraffin (03), Gas (04), Hybrid Gasoline (07), Hybrid Diesel (08), Other Fuel (09), Biodiesel (10), Biogasoline (11), LPG-gas (12), CNG-gas (13), Methanol (14), Ethanol (15). Note 3: #Note that Hydrogen (06) is green, but omitted in this analysis because of negligible ownership numbers. endblock textblock ::::: Passenger Vehicles 2005. endblock // Vehicles 2005 create-dataset vehicle_DS_passenger05 // KJORETOY_KJT_GRUP and KJORETOY_TOT_VEKT: These variables show the division of the car fleet into vehicle groups following the vehicle regulations of 4 October 1994 § 2-2 and regulations on one-off tax - on motor vehicles of 19 March 2001. The codes are used in the Vehicle Register operated by the Norwegian Road Administration. The variables include registered vehicles as of 31 December for each year. Observations with the values ​​0 and unspecified (missing) are omitted. import db/KJORETOY_KJT_GRUP 2005-12-31 as vehicle_group_code05 keep if vehicle_group_code05 == '101' // keep only passenger cars (also, no ambulances) // To find individuals owning passenger vehicles in Norway, vehicles are linked to people using KJORETOY_KJORETOYID_FNR. import db/KJORETOY_KJORETOYID_FNR 2005-12-31 as vehicle_individual_id05 import db/KJORETOY_DRIVSTOFF_OMK 2005-12-31 as fuel_type05 define-labels fuel_type_txt '01' 'Gasoline (Petrol)' '02' 'Diesel' '03' 'Paraffin' '04' 'Gas' '05' 'Electric' '06' 'Hydrogen' '07' 'Hybrid Gasoline' '08' 'Hybrid Diesel' '09' 'Other Fuel' '10' 'Biodiesel' '11' 'Biogasoline' '12' 'LPG-gas' '13' 'CNG-gas' '14' 'Methanol' '15' 'Ethanol' assign-labels fuel_type05 fuel_type_txt tabulate fuel_type05, missing piechart fuel_type05 textblock Private Registered Vehicles in Norway in 2005 ------------------- ::::: Gray vs. Green. endblock // Assign vehicles to emission categories (approach Gray vs. Green) generate emission_categories_gray_green05 = fuel_type05 replace emission_categories_gray_green05 = 'Green' if emission_categories_gray_green05 == '05' replace emission_categories_gray_green05 = 'Gray' if emission_categories_gray_green05 == '01' | emission_categories_gray_green05 == '02' | emission_categories_gray_green05 == '03' | emission_categories_gray_green05 == '04' | emission_categories_gray_green05 == '07' | emission_categories_gray_green05 == '08' | emission_categories_gray_green05 == '09' | emission_categories_gray_green05 == '10' | emission_categories_gray_green05 == '11' | emission_categories_gray_green05 == '12' | emission_categories_gray_green05 == '13' | emission_categories_gray_green05 == '15' drop if emission_categories_gray_green05 == '06' // Tag vehicles by the numerical value of 0 (false) and 1 (true) within each emission category. generate vehicle_green05 = 0 replace vehicle_green05 = 1 if emission_categories_gray_green05 == 'Green' generate vehicle_gray05 = 0 replace vehicle_gray05 = 1 if emission_categories_gray_green05 == 'Gray' piechart emission_categories_gray_green05 tabulate emission_categories_gray_green05, missing //tabulate vehicle_green05 vehicle_gray05, missing // Import the first registration year (model year) of the vehicles in Norway in 2005. //import db/KJORETOY_FREG_AR 2005-12-31 as vehicle_reg_year05 //histogram vehicle_reg_year05, freq //histogram vehicle_reg_year05 if emission_categories_gray_green05 == 'Green', freq //drop if vehicle_reg_year05 < 2005 //summarize vehicle_reg_year05 if vehicle_reg_year05 == 2005 // Tag vehicles by the numerical value of 0 (false) and 1 (true) within each emission category to retrieve newly registered vehicles per year. //generate vehicle_new05 = 0 //replace vehicle_new05 = 1 if vehicle_reg_year05 == 2005 //summarize vehicle_new05 if vehicle_reg_year05 == 2005 //generate vehicle_green_new05 = 0 //replace vehicle_green_new05 = 1 if emission_categories_gray_green05 == 'Green' & vehicle_reg_year05 == 2005 //summarize vehicle_green_new05 if emission_categories_gray_green05 == 'Green' & vehicle_reg_year05 == 2005 //generate vehicle_gray_new05 = 0 //replace vehicle_gray_new05 = 1 if emission_categories_gray_green05 == 'Gray' & vehicle_reg_year05 == 2005 //summarize vehicle_gray_new05 if emission_categories_gray_green05 == 'Gray' & vehicle_reg_year05 == 2005 //tabulate vehicle_green05 vehicle_gray05, missing // Make temporary clones of vehicle_DS_passenger for further analysis of the year 2005. clone-dataset vehicle_DS_passenger05 vehicle_DS_passenger_green_owned05 clone-dataset vehicle_DS_passenger05 vehicle_DS_passenger_gray_owned05 //clone-dataset vehicle_DS_passenger05 vehicle_DS_passenger_all_fuel_regist05 //clone-dataset vehicle_DS_passenger05 vehicle_DS_passenger_green_regist05 //clone-dataset vehicle_DS_passenger05 vehicle_DS_passenger_gray_regist05 // Make temporary datasets to calculate categories of passenger vehicles per household in 2005. clone-dataset person_DS_Y05 household_DS_all_fuel_owners05 clone-dataset person_DS_Y05 household_DS_green_owners05 clone-dataset person_DS_Y05 household_DS_gray_owners05 //clone-dataset person_DS_Y05 household_DS_all_fuel_regist05 //clone-dataset person_DS_Y05 household_DS_green_regist05 //clone-dataset person_DS_Y05 household_DS_gray_regist05 textblock ::::: Owned private vehicles in Norway by Fuel Type in 2005. endblock // Step: At this step, passenger vehicles per person are calculated – irrespective of fuel type in 2005. collapse(count) fuel_type05, by(vehicle_individual_id05) rename fuel_type05 owned_vehicle_all_per_person05 //tabulate owned_vehicle_all_per_person05, missing merge owned_vehicle_all_per_person05 into household_DS_all_fuel_owners05 on household_id05 delete-dataset vehicle_DS_passenger05 // Then, aggregate the number of all categories of passenger vehicles per household in 2005. use household_DS_all_fuel_owners05 collapse(sum) owned_vehicle_all_per_person05, by(household_id05) rename owned_vehicle_all_per_person05 owned_vehicle_all_per_household05 //tabulate owned_vehicle_all_per_household05, missing histogram owned_vehicle_all_per_household05 if owned_vehicle_all_per_household05 > 0, freq //piechart owned_vehicle_all_per_household05 if owned_vehicle_all_per_household05 > 0 piechart owned_vehicle_all_per_household05 merge owned_vehicle_all_per_household05 into household_DS_all on PERSONID_1 delete-dataset household_DS_all_fuel_owners05 // Step: Sum the number of green vehicles per person in 2005. use vehicle_DS_passenger_green_owned05 collapse(sum) vehicle_green05, by(vehicle_individual_id05) rename vehicle_green05 owned_vehicle_green_per_person05 //tabulate owned_vehicle_green_per_person05, missing merge owned_vehicle_green_per_person05 into household_DS_green_owners05 on household_id05 delete-dataset vehicle_DS_passenger_green_owned05 // Then, aggregate the number of green vehicles per household in 2005. use household_DS_green_owners05 collapse(sum) owned_vehicle_green_per_person05, by(household_id05) rename owned_vehicle_green_per_person05 owned_vehicle_green_per_household05 //tabulate owned_vehicle_green_per_household05, missing histogram owned_vehicle_green_per_household05 if owned_vehicle_green_per_household05 > 0, freq piechart owned_vehicle_green_per_household05 if owned_vehicle_green_per_household05 > 0 piechart owned_vehicle_green_per_household05 // Merge green vehicle ownership data into the main dataset merge owned_vehicle_green_per_household05 into household_DS_all on PERSONID_1 delete-dataset household_DS_green_owners05 // Step: Sum the number of gray vehicles per person in 2005. use vehicle_DS_passenger_gray_owned05 collapse(sum) vehicle_gray05, by(vehicle_individual_id05) rename vehicle_gray05 owned_vehicle_gray_per_person05 //tabulate owned_vehicle_gray_per_person05, missing merge owned_vehicle_gray_per_person05 into household_DS_gray_owners05 on household_id05 delete-dataset vehicle_DS_passenger_gray_owned05 // Then, aggregate the number of gray vehicles per household in 2005. use household_DS_gray_owners05 collapse(sum) owned_vehicle_gray_per_person05, by(household_id05) rename owned_vehicle_gray_per_person05 owned_vehicle_gray_per_household05 merge owned_vehicle_gray_per_household05 into household_DS_all on PERSONID_1 delete-dataset household_DS_gray_owners05 textblock // Step: Sum the number of all vehicles newly registered per person in 2005. use vehicle_DS_passenger_all_fuel_regist05 collapse(sum) vehicle_new05, by(vehicle_individual_id05) rename vehicle_new05 regist_vehicle_all_per_person05 merge regist_vehicle_all_per_person05 into household_DS_all_fuel_regist05 on household_id05 delete-dataset vehicle_DS_passenger_all_fuel_regist05 // Then, aggregate the number of all vehicles newly registered per household in 2005 use household_DS_all_fuel_regist05 collapse(sum) regist_vehicle_all_per_person05, by(household_id05) rename regist_vehicle_all_per_person05 regist_vehicle_all_per_household05 //tabulate regist_vehicle_all_per_household05, missing histogram regist_vehicle_all_per_household05 if regist_vehicle_all_per_household05 > 0, freq piechart regist_vehicle_all_per_household05 if regist_vehicle_all_per_household05 > 0 piechart regist_vehicle_all_per_household05 merge regist_vehicle_all_per_household05 into household_DS_all on PERSONID_1 delete-dataset household_DS_all_fuel_regist05 // Step: Sum the number of green vehicles newly registered per person in 2005. use vehicle_DS_passenger_green_regist05 collapse(sum) vehicle_green_new05, by(vehicle_individual_id05) rename vehicle_green_new05 regist_vehicle_green_per_person05 merge regist_vehicle_green_per_person05 into household_DS_green_regist05 on household_id05 delete-dataset vehicle_DS_passenger_green_regist05 // Then, aggregate the number of green vehicles newly registered per household in 2005. use household_DS_green_regist05 collapse(sum) regist_vehicle_green_per_person05, by(household_id05) rename regist_vehicle_green_per_person05 regist_vehicle_green_per_household05 //tabulate regist_vehicle_green_per_household05, missing //histogram regist_vehicle_green_per_household05 if regist_vehicle_green_per_household05 > 0, freq //piechart regist_vehicle_green_per_household05 if regist_vehicle_green_per_household05 > 0 // Merge newly registered regreen vehicles into the main dataset merge regist_vehicle_green_per_household05 into household_DS_all on PERSONID_1 delete-dataset household_DS_green_regist05 // Step: Sum the number of gray vehicles newly registered per person in 2005. use vehicle_DS_passenger_gray_regist05 collapse(sum) vehicle_gray_new05, by(vehicle_individual_id05) rename vehicle_gray_new05 regist_vehicle_gray_per_person05 merge regist_vehicle_gray_per_person05 into household_DS_gray_regist05 on household_id05 delete-dataset vehicle_DS_passenger_gray_regist05 // Then, aggregate the number of gray vehicles newly registered per household in 2005. use household_DS_gray_regist05 collapse(sum) regist_vehicle_gray_per_person05, by(household_id05) rename regist_vehicle_gray_per_person05 regist_vehicle_gray_per_household05 //tabulate regist_vehicle_gray_per_household05, missing //histogram regist_vehicle_gray_per_household05 if regist_vehicle_gray_per_household05 > 0, freq //piechart regist_vehicle_gray_per_household05 if regist_vehicle_gray_per_household05 > 0 merge regist_vehicle_gray_per_household05 into household_DS_all on PERSONID_1 delete-dataset household_DS_gray_regist05 endblock // Vehicles 2006 create-dataset vehicle_DS_passenger06 import db/KJORETOY_KJT_GRUP 2006-12-31 as vehicle_group_code06 keep if vehicle_group_code06 == '101' // keep only passenger cars (also no ambulances) // To find individuals owning passenger vehicles in Norway, vehicles are linked to people using KJORETOY_KJORETOYID_FNR. import db/KJORETOY_KJORETOYID_FNR 2006-12-31 as vehicle_individual_id06 import db/KJORETOY_DRIVSTOFF_OMK 2006-12-31 as fuel_type06 assign-labels fuel_type06 fuel_type_txt tabulate fuel_type06, missing piechart fuel_type06 // Assign vehicles to emission categories (approach Gray vs. Green) generate emission_categories_gray_green06 = fuel_type06 replace emission_categories_gray_green06 = 'Green' if emission_categories_gray_green06 == '05' replace emission_categories_gray_green06 = 'Gray' if emission_categories_gray_green06 == '01' | emission_categories_gray_green06 == '02' | emission_categories_gray_green06 == '03' | emission_categories_gray_green06 == '04' | emission_categories_gray_green06 == '07' | emission_categories_gray_green06 == '08' | emission_categories_gray_green06 == '09' | emission_categories_gray_green06 == '10' | emission_categories_gray_green06 == '11' | emission_categories_gray_green06 == '12' | emission_categories_gray_green06 == '13' | emission_categories_gray_green06 == '15' drop if emission_categories_gray_green06 == '06' // Tag vehicles by the numerical value of 0 (false) and 1 (true) within each emission category. generate vehicle_green06 = 0 replace vehicle_green06 = 1 if emission_categories_gray_green06 == 'Green' generate vehicle_gray06 = 0 replace vehicle_gray06 = 1 if emission_categories_gray_green06 == 'Gray' piechart emission_categories_gray_green06 tabulate emission_categories_gray_green06, missing //tabulate vehicle_green06 vehicle_gray06, missing // Make temporary clones of vehicle_DS_passenger for further analysis of the year 2006. clone-dataset vehicle_DS_passenger06 vehicle_DS_passenger_green_owned06 clone-dataset vehicle_DS_passenger06 vehicle_DS_passenger_gray_owned06 // Make temporary datasets to calculate categories of passenger vehicles per household in 2006. clone-dataset person_DS_Y06 household_DS_all_fuel_owners06 clone-dataset person_DS_Y06 household_DS_green_owners06 clone-dataset person_DS_Y06 household_DS_gray_owners06 textblock ::::: Owned private vehicles in Norway by Fuel Type in 2006. endblock // Step: At this step, passenger vehicles per person are calculated – irrespective of fuel type in 2006. collapse(count) fuel_type06, by(vehicle_individual_id06) rename fuel_type06 owned_vehicle_all_per_person06 //tabulate owned_vehicle_all_per_person06, missing merge owned_vehicle_all_per_person06 into household_DS_all_fuel_owners06 on household_id06 delete-dataset vehicle_DS_passenger06 // Then, aggregate the number of all categories of passenger vehicles per household in 2006. use household_DS_all_fuel_owners06 collapse(sum) owned_vehicle_all_per_person06, by(household_id06) rename owned_vehicle_all_per_person06 owned_vehicle_all_per_household06 //tabulate owned_vehicle_all_per_household06, missing histogram owned_vehicle_all_per_household06 if owned_vehicle_all_per_household06 > 0, freq //piechart owned_vehicle_all_per_household06 if owned_vehicle_all_per_household06 > 0 piechart owned_vehicle_all_per_household06 merge owned_vehicle_all_per_household06 into household_DS_all on PERSONID_1 delete-dataset household_DS_all_fuel_owners06 // Step: Sum the number of green vehicles per person in 2006. use vehicle_DS_passenger_green_owned06 collapse(sum) vehicle_green06, by(vehicle_individual_id06) rename vehicle_green06 owned_vehicle_green_per_person06 //tabulate owned_vehicle_green_per_person06, missing merge owned_vehicle_green_per_person06 into household_DS_green_owners06 on household_id06 delete-dataset vehicle_DS_passenger_green_owned06 // Then, aggregate the number of green vehicles per household in 2006. use household_DS_green_owners06 collapse(sum) owned_vehicle_green_per_person06, by(household_id06) rename owned_vehicle_green_per_person06 owned_vehicle_green_per_household06 //tabulate owned_vehicle_green_per_household06, missing histogram owned_vehicle_green_per_household06 if owned_vehicle_green_per_household06 > 0, freq piechart owned_vehicle_green_per_household06 if owned_vehicle_green_per_household06 > 0 piechart owned_vehicle_green_per_household06 // Merge green vehicle ownership data into the main dataset merge owned_vehicle_green_per_household06 into household_DS_all on PERSONID_1 delete-dataset household_DS_green_owners06 // Step: Sum the number of gray vehicles per person in 2006. use vehicle_DS_passenger_gray_owned06 collapse(sum) vehicle_gray06, by(vehicle_individual_id06) rename vehicle_gray06 owned_vehicle_gray_per_person06 //tabulate owned_vehicle_gray_per_person06, missing merge owned_vehicle_gray_per_person06 into household_DS_gray_owners06 on household_id06 delete-dataset vehicle_DS_passenger_gray_owned06 // Then, aggregate the number of gray vehicles per household in 2006. use household_DS_gray_owners06 collapse(sum) owned_vehicle_gray_per_person06, by(household_id06) rename owned_vehicle_gray_per_person06 owned_vehicle_gray_per_household06 merge owned_vehicle_gray_per_household06 into household_DS_all on PERSONID_1 delete-dataset household_DS_gray_owners06 // Vehicles 2007 create-dataset vehicle_DS_passenger07 import db/KJORETOY_KJT_GRUP 2007-12-31 as vehicle_group_code07 keep if vehicle_group_code07 == '101' // keep only passenger cars (also no ambulances) // To find individuals owning passenger vehicles in Norway, vehicles are linked to people using KJORETOY_KJORETOYID_FNR. import db/KJORETOY_KJORETOYID_FNR 2007-12-31 as vehicle_individual_id07 import db/KJORETOY_DRIVSTOFF_OMK 2007-12-31 as fuel_type07 assign-labels fuel_type07 fuel_type_txt tabulate fuel_type07, missing piechart fuel_type07 // Assign vehicles to emission categories (approach Gray vs. Green) generate emission_categories_gray_green07 = fuel_type07 replace emission_categories_gray_green07 = 'Green' if emission_categories_gray_green07 == '05' replace emission_categories_gray_green07 = 'Gray' if emission_categories_gray_green07 == '01' | emission_categories_gray_green07 == '02' | emission_categories_gray_green07 == '03' | emission_categories_gray_green07 == '04' | emission_categories_gray_green07 == '07' | emission_categories_gray_green07 == '08' | emission_categories_gray_green07 == '09' | emission_categories_gray_green07 == '10' | emission_categories_gray_green07 == '11' | emission_categories_gray_green07 == '12' | emission_categories_gray_green07 == '13' | emission_categories_gray_green07 == '15' drop if emission_categories_gray_green07 == '06' // Tag vehicles by the numerical value of 0 (false) and 1 (true) within each emission category. generate vehicle_green07 = 0 replace vehicle_green07 = 1 if emission_categories_gray_green07 == 'Green' generate vehicle_gray07 = 0 replace vehicle_gray07 = 1 if emission_categories_gray_green07 == 'Gray' piechart emission_categories_gray_green07 tabulate emission_categories_gray_green07, missing //tabulate vehicle_green07 vehicle_gray07, missing // Make temporary clones of vehicle_DS_passenger for further analysis of the year 2007. clone-dataset vehicle_DS_passenger07 vehicle_DS_passenger_green_owned07 clone-dataset vehicle_DS_passenger07 vehicle_DS_passenger_gray_owned07 // Make temporary datasets to calculate categories of passenger vehicles per household in 2007. clone-dataset person_DS_Y07 household_DS_all_fuel_owners07 clone-dataset person_DS_Y07 household_DS_green_owners07 clone-dataset person_DS_Y07 household_DS_gray_owners07 textblock ::::: Owned private vehicles in Norway by Fuel Type in 2007. endblock // Step: At this step, passenger vehicles per person are calculated – irrespective of fuel type in 2007. collapse(count) fuel_type07, by(vehicle_individual_id07) rename fuel_type07 owned_vehicle_all_per_person07 //tabulate owned_vehicle_all_per_person07, missing merge owned_vehicle_all_per_person07 into household_DS_all_fuel_owners07 on household_id07 delete-dataset vehicle_DS_passenger07 // Then, aggregate the number of all categories of passenger vehicles per household in 2007. use household_DS_all_fuel_owners07 collapse(sum) owned_vehicle_all_per_person07, by(household_id07) rename owned_vehicle_all_per_person07 owned_vehicle_all_per_household07 //tabulate owned_vehicle_all_per_household07, missing histogram owned_vehicle_all_per_household07 if owned_vehicle_all_per_household07 > 0, freq //piechart owned_vehicle_all_per_household07 if owned_vehicle_all_per_household07 > 0 piechart owned_vehicle_all_per_household07 merge owned_vehicle_all_per_household07 into household_DS_all on PERSONID_1 delete-dataset household_DS_all_fuel_owners07 // Step: Sum the number of green vehicles per person in 2007. use vehicle_DS_passenger_green_owned07 collapse(sum) vehicle_green07, by(vehicle_individual_id07) rename vehicle_green07 owned_vehicle_green_per_person07 //tabulate owned_vehicle_green_per_person07, missing merge owned_vehicle_green_per_person07 into household_DS_green_owners07 on household_id07 delete-dataset vehicle_DS_passenger_green_owned07 // Then, aggregate the number of green vehicles per household in 2007. use household_DS_green_owners07 collapse(sum) owned_vehicle_green_per_person07, by(household_id07) rename owned_vehicle_green_per_person07 owned_vehicle_green_per_household07 //tabulate owned_vehicle_green_per_household07, missing histogram owned_vehicle_green_per_household07 if owned_vehicle_green_per_household07 > 0, freq piechart owned_vehicle_green_per_household07 if owned_vehicle_green_per_household07 > 0 piechart owned_vehicle_green_per_household07 // Merge green vehicle ownership data into the main dataset merge owned_vehicle_green_per_household07 into household_DS_all on PERSONID_1 delete-dataset household_DS_green_owners07 // Step: Sum the number of gray vehicles per person in 2007. use vehicle_DS_passenger_gray_owned07 collapse(sum) vehicle_gray07, by(vehicle_individual_id07) rename vehicle_gray07 owned_vehicle_gray_per_person07 //tabulate owned_vehicle_gray_per_person07, missing merge owned_vehicle_gray_per_person07 into household_DS_gray_owners07 on household_id07 delete-dataset vehicle_DS_passenger_gray_owned07 // Then, aggregate the number of gray vehicles per household in 2007. use household_DS_gray_owners07 collapse(sum) owned_vehicle_gray_per_person07, by(household_id07) rename owned_vehicle_gray_per_person07 owned_vehicle_gray_per_household07 merge owned_vehicle_gray_per_household07 into household_DS_all on PERSONID_1 delete-dataset household_DS_gray_owners07 // Vehicles 2008 create-dataset vehicle_DS_passenger08 import db/KJORETOY_KJT_GRUP 2008-12-31 as vehicle_group_code08 keep if vehicle_group_code08 == '101' // keep only passenger cars (also no ambulances) // To find individuals owning passenger vehicles in Norway, vehicles are linked to people using KJORETOY_KJORETOYID_FNR. import db/KJORETOY_KJORETOYID_FNR 2008-12-31 as vehicle_individual_id08 import db/KJORETOY_DRIVSTOFF_OMK 2008-12-31 as fuel_type08 assign-labels fuel_type08 fuel_type_txt tabulate fuel_type08, missing piechart fuel_type08 // Assign vehicles to emission categories (approach Gray vs. Green) generate emission_categories_gray_green08 = fuel_type08 replace emission_categories_gray_green08 = 'Green' if emission_categories_gray_green08 == '05' replace emission_categories_gray_green08 = 'Gray' if emission_categories_gray_green08 == '01' | emission_categories_gray_green08 == '02' | emission_categories_gray_green08 == '03' | emission_categories_gray_green08 == '04' | emission_categories_gray_green08 == '07' | emission_categories_gray_green08 == '08' | emission_categories_gray_green08 == '09' | emission_categories_gray_green08 == '10' | emission_categories_gray_green08 == '11' | emission_categories_gray_green08 == '12' | emission_categories_gray_green08 == '13' | emission_categories_gray_green08 == '15' drop if emission_categories_gray_green08 == '06' // Tag vehicles by the numerical value of 0 (false) and 1 (true) within each emission category. generate vehicle_green08 = 0 replace vehicle_green08 = 1 if emission_categories_gray_green08 == 'Green' generate vehicle_gray08 = 0 replace vehicle_gray08 = 1 if emission_categories_gray_green08 == 'Gray' piechart emission_categories_gray_green08 tabulate emission_categories_gray_green08, missing //tabulate vehicle_green08 vehicle_gray08, missing // Make temporary clones of vehicle_DS_passenger for further analysis of the year 2008. clone-dataset vehicle_DS_passenger08 vehicle_DS_passenger_green_owned08 clone-dataset vehicle_DS_passenger08 vehicle_DS_passenger_gray_owned08 // Make temporary datasets to calculate categories of passenger vehicles per household in 2008. clone-dataset person_DS_Y08 household_DS_all_fuel_owners08 clone-dataset person_DS_Y08 household_DS_green_owners08 clone-dataset person_DS_Y08 household_DS_gray_owners08 textblock ::::: Owned private vehicles in Norway by Fuel Type in 2008. endblock // Step: At this step, passenger vehicles per person are calculated – irrespective of fuel type in 2008. collapse(count) fuel_type08, by(vehicle_individual_id08) rename fuel_type08 owned_vehicle_all_per_person08 //tabulate owned_vehicle_all_per_person08, missing merge owned_vehicle_all_per_person08 into household_DS_all_fuel_owners08 on household_id08 delete-dataset vehicle_DS_passenger08 // Then, aggregate the number of all categories of passenger vehicles per household in 2008. use household_DS_all_fuel_owners08 collapse(sum) owned_vehicle_all_per_person08, by(household_id08) rename owned_vehicle_all_per_person08 owned_vehicle_all_per_household08 //tabulate owned_vehicle_all_per_household08, missing histogram owned_vehicle_all_per_household08 if owned_vehicle_all_per_household08 > 0, freq //piechart owned_vehicle_all_per_household08 if owned_vehicle_all_per_household08 > 0 piechart owned_vehicle_all_per_household08 merge owned_vehicle_all_per_household08 into household_DS_all on PERSONID_1 delete-dataset household_DS_all_fuel_owners08 // Step: Sum the number of green vehicles per person in 2008. use vehicle_DS_passenger_green_owned08 collapse(sum) vehicle_green08, by(vehicle_individual_id08) rename vehicle_green08 owned_vehicle_green_per_person08 //tabulate owned_vehicle_green_per_person08, missing merge owned_vehicle_green_per_person08 into household_DS_green_owners08 on household_id08 delete-dataset vehicle_DS_passenger_green_owned08 // Then, aggregate the number of green vehicles per household in 2008. use household_DS_green_owners08 collapse(sum) owned_vehicle_green_per_person08, by(household_id08) rename owned_vehicle_green_per_person08 owned_vehicle_green_per_household08 //tabulate owned_vehicle_green_per_household08, missing histogram owned_vehicle_green_per_household08 if owned_vehicle_green_per_household08 > 0, freq piechart owned_vehicle_green_per_household08 if owned_vehicle_green_per_household08 > 0 piechart owned_vehicle_green_per_household08 // Merge green vehicle ownership data into the main dataset merge owned_vehicle_green_per_household08 into household_DS_all on PERSONID_1 delete-dataset household_DS_green_owners08 // Step: Sum the number of gray vehicles per person in 2008. use vehicle_DS_passenger_gray_owned08 collapse(sum) vehicle_gray08, by(vehicle_individual_id08) rename vehicle_gray08 owned_vehicle_gray_per_person08 //tabulate owned_vehicle_gray_per_person08, missing merge owned_vehicle_gray_per_person08 into household_DS_gray_owners08 on household_id08 delete-dataset vehicle_DS_passenger_gray_owned08 // Then, aggregate the number of gray vehicles per household in 2008. use household_DS_gray_owners08 collapse(sum) owned_vehicle_gray_per_person08, by(household_id08) rename owned_vehicle_gray_per_person08 owned_vehicle_gray_per_household08 merge owned_vehicle_gray_per_household08 into household_DS_all on PERSONID_1 delete-dataset household_DS_gray_owners08 // Vehicles 2009 create-dataset vehicle_DS_passenger09 import db/KJORETOY_KJT_GRUP 2009-12-31 as vehicle_group_code09 keep if vehicle_group_code09 == '101' // keep only passenger cars (also no ambulances) // To find individuals owning passenger vehicles in Norway, vehicles are linked to people using KJORETOY_KJORETOYID_FNR. import db/KJORETOY_KJORETOYID_FNR 2009-12-31 as vehicle_individual_id09 import db/KJORETOY_DRIVSTOFF_OMK 2009-12-31 as fuel_type09 assign-labels fuel_type09 fuel_type_txt tabulate fuel_type09, missing piechart fuel_type09 // Assign vehicles to emission categories (approach Gray vs. Green) generate emission_categories_gray_green09 = fuel_type09 replace emission_categories_gray_green09 = 'Green' if emission_categories_gray_green09 == '05' replace emission_categories_gray_green09 = 'Gray' if emission_categories_gray_green09 == '01' | emission_categories_gray_green09 == '02' | emission_categories_gray_green09 == '03' | emission_categories_gray_green09 == '04' | emission_categories_gray_green09 == '07' | emission_categories_gray_green09 == '08' | emission_categories_gray_green09 == '09' | emission_categories_gray_green09 == '10' | emission_categories_gray_green09 == '11' | emission_categories_gray_green09 == '12' | emission_categories_gray_green09 == '13' | emission_categories_gray_green09 == '15' drop if emission_categories_gray_green09 == '06' // Tag vehicles by the numerical value of 0 (false) and 1 (true) within each emission category. generate vehicle_green09 = 0 replace vehicle_green09 = 1 if emission_categories_gray_green09 == 'Green' generate vehicle_gray09 = 0 replace vehicle_gray09 = 1 if emission_categories_gray_green09 == 'Gray' piechart emission_categories_gray_green09 tabulate emission_categories_gray_green09, missing //tabulate vehicle_green09 vehicle_gray09, missing // Make temporary clones of vehicle_DS_passenger for further analysis of the year 2009. clone-dataset vehicle_DS_passenger09 vehicle_DS_passenger_green_owned09 clone-dataset vehicle_DS_passenger09 vehicle_DS_passenger_gray_owned09 // Make temporary datasets to calculate categories of passenger vehicles per household in 2009. clone-dataset person_DS_Y09 household_DS_all_fuel_owners09 clone-dataset person_DS_Y09 household_DS_green_owners09 clone-dataset person_DS_Y09 household_DS_gray_owners09 textblock ::::: Owned private vehicles in Norway by Fuel Type in 2009. endblock // Step: At this step, passenger vehicles per person are calculated – irrespective of fuel type in 2009. collapse(count) fuel_type09, by(vehicle_individual_id09) rename fuel_type09 owned_vehicle_all_per_person09 //tabulate owned_vehicle_all_per_person09, missing merge owned_vehicle_all_per_person09 into household_DS_all_fuel_owners09 on household_id09 delete-dataset vehicle_DS_passenger09 // Then, aggregate the number of all categories of passenger vehicles per household in 2009. use household_DS_all_fuel_owners09 collapse(sum) owned_vehicle_all_per_person09, by(household_id09) rename owned_vehicle_all_per_person09 owned_vehicle_all_per_household09 //tabulate owned_vehicle_all_per_household09, missing histogram owned_vehicle_all_per_household09 if owned_vehicle_all_per_household09 > 0, freq //piechart owned_vehicle_all_per_household09 if owned_vehicle_all_per_household09 > 0 piechart owned_vehicle_all_per_household09 merge owned_vehicle_all_per_household09 into household_DS_all on PERSONID_1 delete-dataset household_DS_all_fuel_owners09 // Step: Sum the number of green vehicles per person in 2009. use vehicle_DS_passenger_green_owned09 collapse(sum) vehicle_green09, by(vehicle_individual_id09) rename vehicle_green09 owned_vehicle_green_per_person09 //tabulate owned_vehicle_green_per_person09, missing merge owned_vehicle_green_per_person09 into household_DS_green_owners09 on household_id09 delete-dataset vehicle_DS_passenger_green_owned09 // Then, aggregate the number of green vehicles per household in 2009. use household_DS_green_owners09 collapse(sum) owned_vehicle_green_per_person09, by(household_id09) rename owned_vehicle_green_per_person09 owned_vehicle_green_per_household09 //tabulate owned_vehicle_green_per_household09, missing histogram owned_vehicle_green_per_household09 if owned_vehicle_green_per_household09 > 0, freq piechart owned_vehicle_green_per_household09 if owned_vehicle_green_per_household09 > 0 piechart owned_vehicle_green_per_household09 // Merge green vehicle ownership data into the main dataset merge owned_vehicle_green_per_household09 into household_DS_all on PERSONID_1 delete-dataset household_DS_green_owners09 // Step: Sum the number of gray vehicles per person in 2009. use vehicle_DS_passenger_gray_owned09 collapse(sum) vehicle_gray09, by(vehicle_individual_id09) rename vehicle_gray09 owned_vehicle_gray_per_person09 //tabulate owned_vehicle_gray_per_person09, missing merge owned_vehicle_gray_per_person09 into household_DS_gray_owners09 on household_id09 delete-dataset vehicle_DS_passenger_gray_owned09 // Then, aggregate the number of gray vehicles per household in 2009. use household_DS_gray_owners09 collapse(sum) owned_vehicle_gray_per_person09, by(household_id09) rename owned_vehicle_gray_per_person09 owned_vehicle_gray_per_household09 merge owned_vehicle_gray_per_household09 into household_DS_all on PERSONID_1 delete-dataset household_DS_gray_owners09 // Vehicles 2010 create-dataset vehicle_DS_passenger10 import db/KJORETOY_KJT_GRUP 2010-12-31 as vehicle_group_code10 keep if vehicle_group_code10 == '101' // keep only passenger cars (also no ambulances) // To find individuals owning passenger vehicles in Norway, vehicles are linked to people using KJORETOY_KJORETOYID_FNR. import db/KJORETOY_KJORETOYID_FNR 2010-12-31 as vehicle_individual_id10 import db/KJORETOY_DRIVSTOFF_OMK 2010-12-31 as fuel_type10 assign-labels fuel_type10 fuel_type_txt tabulate fuel_type10, missing piechart fuel_type10 // Assign vehicles to emission categories (approach Gray vs. Green) generate emission_categories_gray_green10 = fuel_type10 replace emission_categories_gray_green10 = 'Green' if emission_categories_gray_green10 == '05' replace emission_categories_gray_green10 = 'Gray' if emission_categories_gray_green10 == '01' | emission_categories_gray_green10 == '02' | emission_categories_gray_green10 == '03' | emission_categories_gray_green10 == '04' | emission_categories_gray_green10 == '07' | emission_categories_gray_green10 == '08' | emission_categories_gray_green10 == '09' | emission_categories_gray_green10 == '10' | emission_categories_gray_green10 == '11' | emission_categories_gray_green10 == '12' | emission_categories_gray_green10 == '13' | emission_categories_gray_green10 == '15' drop if emission_categories_gray_green10 == '06' // Tag vehicles by the numerical value of 0 (false) and 1 (true) within each emission category. generate vehicle_green10 = 0 replace vehicle_green10 = 1 if emission_categories_gray_green10 == 'Green' generate vehicle_gray10 = 0 replace vehicle_gray10 = 1 if emission_categories_gray_green10 == 'Gray' piechart emission_categories_gray_green10 tabulate emission_categories_gray_green10, missing //tabulate vehicle_green10 vehicle_gray10, missing // Make temporary clones of vehicle_DS_passenger for further analysis of the year 2010. clone-dataset vehicle_DS_passenger10 vehicle_DS_passenger_green_owned10 clone-dataset vehicle_DS_passenger10 vehicle_DS_passenger_gray_owned10 // Make temporary datasets to calculate categories of passenger vehicles per household in 2010. clone-dataset person_DS_Y10 household_DS_all_fuel_owners10 clone-dataset person_DS_Y10 household_DS_green_owners10 clone-dataset person_DS_Y10 household_DS_gray_owners10 textblock ::::: Owned private vehicles in Norway by Fuel Type in 2010. endblock // Step: At this step, passenger vehicles per person are calculated – irrespective of fuel type in 2010. collapse(count) fuel_type10, by(vehicle_individual_id10) rename fuel_type10 owned_vehicle_all_per_person10 //tabulate owned_vehicle_all_per_person10, missing merge owned_vehicle_all_per_person10 into household_DS_all_fuel_owners10 on household_id10 delete-dataset vehicle_DS_passenger10 // Then, aggregate the number of all categories of passenger vehicles per household in 2010. use household_DS_all_fuel_owners10 collapse(sum) owned_vehicle_all_per_person10, by(household_id10) rename owned_vehicle_all_per_person10 owned_vehicle_all_per_household10 //tabulate owned_vehicle_all_per_household10, missing histogram owned_vehicle_all_per_household10 if owned_vehicle_all_per_household10 > 0, freq //piechart owned_vehicle_all_per_household10 if owned_vehicle_all_per_household10 > 0 piechart owned_vehicle_all_per_household10 merge owned_vehicle_all_per_household10 into household_DS_all on PERSONID_1 delete-dataset household_DS_all_fuel_owners10 // Step: Sum the number of green vehicles per person in 2010. use vehicle_DS_passenger_green_owned10 collapse(sum) vehicle_green10, by(vehicle_individual_id10) rename vehicle_green10 owned_vehicle_green_per_person10 //tabulate owned_vehicle_green_per_person10, missing merge owned_vehicle_green_per_person10 into household_DS_green_owners10 on household_id10 delete-dataset vehicle_DS_passenger_green_owned10 // Then, aggregate the number of green vehicles per household in 2010. use household_DS_green_owners10 collapse(sum) owned_vehicle_green_per_person10, by(household_id10) rename owned_vehicle_green_per_person10 owned_vehicle_green_per_household10 //tabulate owned_vehicle_green_per_household10, missing histogram owned_vehicle_green_per_household10 if owned_vehicle_green_per_household10 > 0, freq piechart owned_vehicle_green_per_household10 if owned_vehicle_green_per_household10 > 0 piechart owned_vehicle_green_per_household10 // Merge green vehicle ownership data into the main dataset merge owned_vehicle_green_per_household10 into household_DS_all on PERSONID_1 delete-dataset household_DS_green_owners10 // Step: Sum the number of gray vehicles per person in 2010. use vehicle_DS_passenger_gray_owned10 collapse(sum) vehicle_gray10, by(vehicle_individual_id10) rename vehicle_gray10 owned_vehicle_gray_per_person10 //tabulate owned_vehicle_gray_per_person10, missing merge owned_vehicle_gray_per_person10 into household_DS_gray_owners10 on household_id10 delete-dataset vehicle_DS_passenger_gray_owned10 // Then, aggregate the number of gray vehicles per household in 2010. use household_DS_gray_owners10 collapse(sum) owned_vehicle_gray_per_person10, by(household_id10) rename owned_vehicle_gray_per_person10 owned_vehicle_gray_per_household10 merge owned_vehicle_gray_per_household10 into household_DS_all on PERSONID_1 delete-dataset household_DS_gray_owners10 // Vehicles 2011 create-dataset vehicle_DS_passenger11 import db/KJORETOY_KJT_GRUP 2011-12-31 as vehicle_group_code11 keep if vehicle_group_code11 == '101' // keep only passenger cars (also no ambulances) // To find individuals owning passenger vehicles in Norway, vehicles are linked to people using KJORETOY_KJORETOYID_FNR. import db/KJORETOY_KJORETOYID_FNR 2011-12-31 as vehicle_individual_id11 import db/KJORETOY_DRIVSTOFF_OMK 2011-12-31 as fuel_type11 assign-labels fuel_type11 fuel_type_txt tabulate fuel_type11, missing piechart fuel_type11 // Assign vehicles to emission categories (approach Gray vs. Green) generate emission_categories_gray_green11 = fuel_type11 replace emission_categories_gray_green11 = 'Green' if emission_categories_gray_green11 == '05' replace emission_categories_gray_green11 = 'Gray' if emission_categories_gray_green11 == '01' | emission_categories_gray_green11 == '02' | emission_categories_gray_green11 == '03' | emission_categories_gray_green11 == '04' | emission_categories_gray_green11 == '07' | emission_categories_gray_green11 == '08' | emission_categories_gray_green11 == '09' | emission_categories_gray_green11 == '10' | emission_categories_gray_green11 == '11' | emission_categories_gray_green11 == '12' | emission_categories_gray_green11 == '13' | emission_categories_gray_green11 == '15' drop if emission_categories_gray_green11 == '06' // Tag vehicles by the numerical value of 0 (false) and 1 (true) within each emission category. generate vehicle_green11 = 0 replace vehicle_green11 = 1 if emission_categories_gray_green11 == 'Green' generate vehicle_gray11 = 0 replace vehicle_gray11 = 1 if emission_categories_gray_green11 == 'Gray' piechart emission_categories_gray_green11 tabulate emission_categories_gray_green11, missing //tabulate vehicle_green11 vehicle_gray11, missing // Make temporary clones of vehicle_DS_passenger for further analysis of the year 2011. clone-dataset vehicle_DS_passenger11 vehicle_DS_passenger_green_owned11 clone-dataset vehicle_DS_passenger11 vehicle_DS_passenger_gray_owned11 // Make temporary datasets to calculate categories of passenger vehicles per household in 2011. clone-dataset person_DS_Y11 household_DS_all_fuel_owners11 clone-dataset person_DS_Y11 household_DS_green_owners11 clone-dataset person_DS_Y11 household_DS_gray_owners11 textblock ::::: Owned private vehicles in Norway by Fuel Type in 2011. endblock // Step: At this step, passenger vehicles per person are calculated – irrespective of fuel type in 2011. collapse(count) fuel_type11, by(vehicle_individual_id11) rename fuel_type11 owned_vehicle_all_per_person11 //tabulate owned_vehicle_all_per_person11, missing merge owned_vehicle_all_per_person11 into household_DS_all_fuel_owners11 on household_id11 delete-dataset vehicle_DS_passenger11 // Then, aggregate the number of all categories of passenger vehicles per household in 2011. use household_DS_all_fuel_owners11 collapse(sum) owned_vehicle_all_per_person11, by(household_id11) rename owned_vehicle_all_per_person11 owned_vehicle_all_per_household11 //tabulate owned_vehicle_all_per_household11, missing histogram owned_vehicle_all_per_household11 if owned_vehicle_all_per_household11 > 0, freq //piechart owned_vehicle_all_per_household11 if owned_vehicle_all_per_household11 > 0 piechart owned_vehicle_all_per_household11 merge owned_vehicle_all_per_household11 into household_DS_all on PERSONID_1 delete-dataset household_DS_all_fuel_owners11 // Step: Sum the number of green vehicles per person in 2011. use vehicle_DS_passenger_green_owned11 collapse(sum) vehicle_green11, by(vehicle_individual_id11) rename vehicle_green11 owned_vehicle_green_per_person11 //tabulate owned_vehicle_green_per_person11, missing merge owned_vehicle_green_per_person11 into household_DS_green_owners11 on household_id11 delete-dataset vehicle_DS_passenger_green_owned11 // Then, aggregate the number of green vehicles per household in 2011. use household_DS_green_owners11 collapse(sum) owned_vehicle_green_per_person11, by(household_id11) rename owned_vehicle_green_per_person11 owned_vehicle_green_per_household11 //tabulate owned_vehicle_green_per_household11, missing histogram owned_vehicle_green_per_household11 if owned_vehicle_green_per_household11 > 0, freq piechart owned_vehicle_green_per_household11 if owned_vehicle_green_per_household11 > 0 piechart owned_vehicle_green_per_household11 // Merge green vehicle ownership data into the main dataset merge owned_vehicle_green_per_household11 into household_DS_all on PERSONID_1 delete-dataset household_DS_green_owners11 // Step: Sum the number of gray vehicles per person in 2011. use vehicle_DS_passenger_gray_owned11 collapse(sum) vehicle_gray11, by(vehicle_individual_id11) rename vehicle_gray11 owned_vehicle_gray_per_person11 //tabulate owned_vehicle_gray_per_person11, missing merge owned_vehicle_gray_per_person11 into household_DS_gray_owners11 on household_id11 delete-dataset vehicle_DS_passenger_gray_owned11 // Then, aggregate the number of gray vehicles per household in 2011. use household_DS_gray_owners11 collapse(sum) owned_vehicle_gray_per_person11, by(household_id11) rename owned_vehicle_gray_per_person11 owned_vehicle_gray_per_household11 merge owned_vehicle_gray_per_household11 into household_DS_all on PERSONID_1 delete-dataset household_DS_gray_owners11 // Vehicles 2012 create-dataset vehicle_DS_passenger12 import db/KJORETOY_KJT_GRUP 2012-12-31 as vehicle_group_code12 keep if vehicle_group_code12 == '101' // keep only passenger cars (also no ambulances) // To find individuals owning passenger vehicles in Norway, vehicles are linked to people using KJORETOY_KJORETOYID_FNR. import db/KJORETOY_KJORETOYID_FNR 2012-12-31 as vehicle_individual_id12 import db/KJORETOY_DRIVSTOFF_OMK 2012-12-31 as fuel_type12 assign-labels fuel_type12 fuel_type_txt tabulate fuel_type12, missing piechart fuel_type12 // Assign vehicles to emission categories (approach Gray vs. Green) generate emission_categories_gray_green12 = fuel_type12 replace emission_categories_gray_green12 = 'Green' if emission_categories_gray_green12 == '05' replace emission_categories_gray_green12 = 'Gray' if emission_categories_gray_green12 == '01' | emission_categories_gray_green12 == '02' | emission_categories_gray_green12 == '03' | emission_categories_gray_green12 == '04' | emission_categories_gray_green12 == '07' | emission_categories_gray_green12 == '08' | emission_categories_gray_green12 == '09' | emission_categories_gray_green12 == '10' | emission_categories_gray_green12 == '11' | emission_categories_gray_green12 == '12' | emission_categories_gray_green12 == '13' | emission_categories_gray_green12 == '15' drop if emission_categories_gray_green12 == '06' // Tag vehicles by the numerical value of 0 (false) and 1 (true) within each emission category. generate vehicle_green12 = 0 replace vehicle_green12 = 1 if emission_categories_gray_green12 == 'Green' generate vehicle_gray12 = 0 replace vehicle_gray12 = 1 if emission_categories_gray_green12 == 'Gray' piechart emission_categories_gray_green12 tabulate emission_categories_gray_green12, missing //tabulate vehicle_green12 vehicle_gray12, missing // Make temporary clones of vehicle_DS_passenger for further analysis of the year 2012. clone-dataset vehicle_DS_passenger12 vehicle_DS_passenger_green_owned12 clone-dataset vehicle_DS_passenger12 vehicle_DS_passenger_gray_owned12 // Make temporary datasets to calculate categories of passenger vehicles per household in 2012. clone-dataset person_DS_Y12 household_DS_all_fuel_owners12 clone-dataset person_DS_Y12 household_DS_green_owners12 clone-dataset person_DS_Y12 household_DS_gray_owners12 textblock ::::: Owned private vehicles in Norway by Fuel Type in 2012. endblock // Step: At this step, passenger vehicles per person are calculated – irrespective of fuel type in 2012. collapse(count) fuel_type12, by(vehicle_individual_id12) rename fuel_type12 owned_vehicle_all_per_person12 //tabulate owned_vehicle_all_per_person12, missing merge owned_vehicle_all_per_person12 into household_DS_all_fuel_owners12 on household_id12 delete-dataset vehicle_DS_passenger12 // Then, aggregate the number of all categories of passenger vehicles per household in 2012. use household_DS_all_fuel_owners12 collapse(sum) owned_vehicle_all_per_person12, by(household_id12) rename owned_vehicle_all_per_person12 owned_vehicle_all_per_household12 //tabulate owned_vehicle_all_per_household12, missing histogram owned_vehicle_all_per_household12 if owned_vehicle_all_per_household12 > 0, freq //piechart owned_vehicle_all_per_household12 if owned_vehicle_all_per_household12 > 0 piechart owned_vehicle_all_per_household12 merge owned_vehicle_all_per_household12 into household_DS_all on PERSONID_1 delete-dataset household_DS_all_fuel_owners12 // Step: Sum the number of green vehicles per person in 2012. use vehicle_DS_passenger_green_owned12 collapse(sum) vehicle_green12, by(vehicle_individual_id12) rename vehicle_green12 owned_vehicle_green_per_person12 //tabulate owned_vehicle_green_per_person12, missing merge owned_vehicle_green_per_person12 into household_DS_green_owners12 on household_id12 delete-dataset vehicle_DS_passenger_green_owned12 // Then, aggregate the number of green vehicles per household in 2012. use household_DS_green_owners12 collapse(sum) owned_vehicle_green_per_person12, by(household_id12) rename owned_vehicle_green_per_person12 owned_vehicle_green_per_household12 //tabulate owned_vehicle_green_per_household12, missing histogram owned_vehicle_green_per_household12 if owned_vehicle_green_per_household12 > 0, freq piechart owned_vehicle_green_per_household12 if owned_vehicle_green_per_household12 > 0 piechart owned_vehicle_green_per_household12 // Merge green vehicle ownership data into the main dataset merge owned_vehicle_green_per_household12 into household_DS_all on PERSONID_1 delete-dataset household_DS_green_owners12 // Step: Sum the number of gray vehicles per person in 2012. use vehicle_DS_passenger_gray_owned12 collapse(sum) vehicle_gray12, by(vehicle_individual_id12) rename vehicle_gray12 owned_vehicle_gray_per_person12 //tabulate owned_vehicle_gray_per_person12, missing merge owned_vehicle_gray_per_person12 into household_DS_gray_owners12 on household_id12 delete-dataset vehicle_DS_passenger_gray_owned12 // Then, aggregate the number of gray vehicles per household in 2012. use household_DS_gray_owners12 collapse(sum) owned_vehicle_gray_per_person12, by(household_id12) rename owned_vehicle_gray_per_person12 owned_vehicle_gray_per_household12 merge owned_vehicle_gray_per_household12 into household_DS_all on PERSONID_1 delete-dataset household_DS_gray_owners12 // Vehicles 2013 create-dataset vehicle_DS_passenger13 import db/KJORETOY_KJT_GRUP 2013-12-31 as vehicle_group_code13 keep if vehicle_group_code13 == '101' // keep only passenger cars (also no ambulances) // To find individuals owning passenger vehicles in Norway, vehicles are linked to people using KJORETOY_KJORETOYID_FNR. import db/KJORETOY_KJORETOYID_FNR 2013-12-31 as vehicle_individual_id13 import db/KJORETOY_DRIVSTOFF_OMK 2013-12-31 as fuel_type13 assign-labels fuel_type13 fuel_type_txt tabulate fuel_type13, missing piechart fuel_type13 // Assign vehicles to emission categories (approach Gray vs. Green) generate emission_categories_gray_green13 = fuel_type13 replace emission_categories_gray_green13 = 'Green' if emission_categories_gray_green13 == '05' replace emission_categories_gray_green13 = 'Gray' if emission_categories_gray_green13 == '01' | emission_categories_gray_green13 == '02' | emission_categories_gray_green13 == '03' | emission_categories_gray_green13 == '04' | emission_categories_gray_green13 == '07' | emission_categories_gray_green13 == '08' | emission_categories_gray_green13 == '09' | emission_categories_gray_green13 == '10' | emission_categories_gray_green13 == '11' | emission_categories_gray_green13 == '12' | emission_categories_gray_green13 == '13' | emission_categories_gray_green13 == '15' drop if emission_categories_gray_green13 == '06' // Tag vehicles by the numerical value of 0 (false) and 1 (true) within each emission category. generate vehicle_green13 = 0 replace vehicle_green13 = 1 if emission_categories_gray_green13 == 'Green' generate vehicle_gray13 = 0 replace vehicle_gray13 = 1 if emission_categories_gray_green13 == 'Gray' piechart emission_categories_gray_green13 tabulate emission_categories_gray_green13, missing //tabulate vehicle_green13 vehicle_gray13, missing // Make temporary clones of vehicle_DS_passenger for further analysis of the year 2013. clone-dataset vehicle_DS_passenger13 vehicle_DS_passenger_green_owned13 clone-dataset vehicle_DS_passenger13 vehicle_DS_passenger_gray_owned13 // Make temporary datasets to calculate categories of passenger vehicles per household in 2013. clone-dataset person_DS_Y13 household_DS_all_fuel_owners13 clone-dataset person_DS_Y13 household_DS_green_owners13 clone-dataset person_DS_Y13 household_DS_gray_owners13 textblock ::::: Owned private vehicles in Norway by Fuel Type in 2013. endblock // Step: At this step, passenger vehicles per person are calculated – irrespective of fuel type in 2013. collapse(count) fuel_type13, by(vehicle_individual_id13) rename fuel_type13 owned_vehicle_all_per_person13 //tabulate owned_vehicle_all_per_person13, missing merge owned_vehicle_all_per_person13 into household_DS_all_fuel_owners13 on household_id13 delete-dataset vehicle_DS_passenger13 // Then, aggregate the number of all categories of passenger vehicles per household in 2013. use household_DS_all_fuel_owners13 collapse(sum) owned_vehicle_all_per_person13, by(household_id13) rename owned_vehicle_all_per_person13 owned_vehicle_all_per_household13 //tabulate owned_vehicle_all_per_household13, missing histogram owned_vehicle_all_per_household13 if owned_vehicle_all_per_household13 > 0, freq //piechart owned_vehicle_all_per_household13 if owned_vehicle_all_per_household13 > 0 piechart owned_vehicle_all_per_household13 merge owned_vehicle_all_per_household13 into household_DS_all on PERSONID_1 delete-dataset household_DS_all_fuel_owners13 // Step: Sum the number of green vehicles per person in 2013. use vehicle_DS_passenger_green_owned13 collapse(sum) vehicle_green13, by(vehicle_individual_id13) rename vehicle_green13 owned_vehicle_green_per_person13 //tabulate owned_vehicle_green_per_person13, missing merge owned_vehicle_green_per_person13 into household_DS_green_owners13 on household_id13 delete-dataset vehicle_DS_passenger_green_owned13 // Then, aggregate the number of green vehicles per household in 2013. use household_DS_green_owners13 collapse(sum) owned_vehicle_green_per_person13, by(household_id13) rename owned_vehicle_green_per_person13 owned_vehicle_green_per_household13 //tabulate owned_vehicle_green_per_household13, missing histogram owned_vehicle_green_per_household13 if owned_vehicle_green_per_household13 > 0, freq piechart owned_vehicle_green_per_household13 if owned_vehicle_green_per_household13 > 0 piechart owned_vehicle_green_per_household13 // Merge green vehicle ownership data into the main dataset merge owned_vehicle_green_per_household13 into household_DS_all on PERSONID_1 delete-dataset household_DS_green_owners13 // Step: Sum the number of gray vehicles per person in 2013. use vehicle_DS_passenger_gray_owned13 collapse(sum) vehicle_gray13, by(vehicle_individual_id13) rename vehicle_gray13 owned_vehicle_gray_per_person13 //tabulate owned_vehicle_gray_per_person13, missing merge owned_vehicle_gray_per_person13 into household_DS_gray_owners13 on household_id13 delete-dataset vehicle_DS_passenger_gray_owned13 // Then, aggregate the number of gray vehicles per household in 2013. use household_DS_gray_owners13 collapse(sum) owned_vehicle_gray_per_person13, by(household_id13) rename owned_vehicle_gray_per_person13 owned_vehicle_gray_per_household13 merge owned_vehicle_gray_per_household13 into household_DS_all on PERSONID_1 delete-dataset household_DS_gray_owners13 // Vehicles 2014 create-dataset vehicle_DS_passenger14 import db/KJORETOY_KJT_GRUP 2014-12-31 as vehicle_group_code14 keep if vehicle_group_code14 == '101' // keep only passenger cars (also no ambulances) // To find individuals owning passenger vehicles in Norway, vehicles are linked to people using KJORETOY_KJORETOYID_FNR. import db/KJORETOY_KJORETOYID_FNR 2014-12-31 as vehicle_individual_id14 import db/KJORETOY_DRIVSTOFF_OMK 2014-12-31 as fuel_type14 assign-labels fuel_type14 fuel_type_txt tabulate fuel_type14, missing piechart fuel_type14 // Assign vehicles to emission categories (approach Gray vs. Green) generate emission_categories_gray_green14 = fuel_type14 replace emission_categories_gray_green14 = 'Green' if emission_categories_gray_green14 == '05' replace emission_categories_gray_green14 = 'Gray' if emission_categories_gray_green14 == '01' | emission_categories_gray_green14 == '02' | emission_categories_gray_green14 == '03' | emission_categories_gray_green14 == '04' | emission_categories_gray_green14 == '07' | emission_categories_gray_green14 == '08' | emission_categories_gray_green14 == '09' | emission_categories_gray_green14 == '10' | emission_categories_gray_green14 == '11' | emission_categories_gray_green14 == '12' | emission_categories_gray_green14 == '13' | emission_categories_gray_green14 == '15' drop if emission_categories_gray_green14 == '06' // Tag vehicles by the numerical value of 0 (false) and 1 (true) within each emission category. generate vehicle_green14 = 0 replace vehicle_green14 = 1 if emission_categories_gray_green14 == 'Green' generate vehicle_gray14 = 0 replace vehicle_gray14 = 1 if emission_categories_gray_green14 == 'Gray' piechart emission_categories_gray_green14 tabulate emission_categories_gray_green14, missing //tabulate vehicle_green14 vehicle_gray14, missing // Make temporary clones of vehicle_DS_passenger for further analysis of the year 2014. clone-dataset vehicle_DS_passenger14 vehicle_DS_passenger_green_owned14 clone-dataset vehicle_DS_passenger14 vehicle_DS_passenger_gray_owned14 // Make temporary datasets to calculate categories of passenger vehicles per household in 2014. clone-dataset person_DS_Y14 household_DS_all_fuel_owners14 clone-dataset person_DS_Y14 household_DS_green_owners14 clone-dataset person_DS_Y14 household_DS_gray_owners14 textblock ::::: Owned private vehicles in Norway by Fuel Type in 2014. endblock // Step: At this step, passenger vehicles per person are calculated – irrespective of fuel type in 2014. collapse(count) fuel_type14, by(vehicle_individual_id14) rename fuel_type14 owned_vehicle_all_per_person14 //tabulate owned_vehicle_all_per_person14, missing merge owned_vehicle_all_per_person14 into household_DS_all_fuel_owners14 on household_id14 delete-dataset vehicle_DS_passenger14 // Then, aggregate the number of all categories of passenger vehicles per household in 2014. use household_DS_all_fuel_owners14 collapse(sum) owned_vehicle_all_per_person14, by(household_id14) rename owned_vehicle_all_per_person14 owned_vehicle_all_per_household14 //tabulate owned_vehicle_all_per_household14, missing histogram owned_vehicle_all_per_household14 if owned_vehicle_all_per_household14 > 0, freq //piechart owned_vehicle_all_per_household14 if owned_vehicle_all_per_household14 > 0 piechart owned_vehicle_all_per_household14 merge owned_vehicle_all_per_household14 into household_DS_all on PERSONID_1 delete-dataset household_DS_all_fuel_owners14 // Step: Sum the number of green vehicles per person in 2014. use vehicle_DS_passenger_green_owned14 collapse(sum) vehicle_green14, by(vehicle_individual_id14) rename vehicle_green14 owned_vehicle_green_per_person14 //tabulate owned_vehicle_green_per_person14, missing merge owned_vehicle_green_per_person14 into household_DS_green_owners14 on household_id14 delete-dataset vehicle_DS_passenger_green_owned14 // Then, aggregate the number of green vehicles per household in 2014. use household_DS_green_owners14 collapse(sum) owned_vehicle_green_per_person14, by(household_id14) rename owned_vehicle_green_per_person14 owned_vehicle_green_per_household14 //tabulate owned_vehicle_green_per_household14, missing histogram owned_vehicle_green_per_household14 if owned_vehicle_green_per_household14 > 0, freq piechart owned_vehicle_green_per_household14 if owned_vehicle_green_per_household14 > 0 piechart owned_vehicle_green_per_household14 // Merge green vehicle ownership data into the main dataset merge owned_vehicle_green_per_household14 into household_DS_all on PERSONID_1 delete-dataset household_DS_green_owners14 // Step: Sum the number of gray vehicles per person in 2014. use vehicle_DS_passenger_gray_owned14 collapse(sum) vehicle_gray14, by(vehicle_individual_id14) rename vehicle_gray14 owned_vehicle_gray_per_person14 //tabulate owned_vehicle_gray_per_person14, missing merge owned_vehicle_gray_per_person14 into household_DS_gray_owners14 on household_id14 delete-dataset vehicle_DS_passenger_gray_owned14 // Then, aggregate the number of gray vehicles per household in 2014. use household_DS_gray_owners14 collapse(sum) owned_vehicle_gray_per_person14, by(household_id14) rename owned_vehicle_gray_per_person14 owned_vehicle_gray_per_household14 merge owned_vehicle_gray_per_household14 into household_DS_all on PERSONID_1 delete-dataset household_DS_gray_owners14 // Vehicles 2015 create-dataset vehicle_DS_passenger15 import db/KJORETOY_KJT_GRUP 2015-12-31 as vehicle_group_code15 keep if vehicle_group_code15 == '101' // keep only passenger cars (also no ambulances) // To find individuals owning passenger vehicles in Norway, vehicles are linked to people using KJORETOY_KJORETOYID_FNR. import db/KJORETOY_KJORETOYID_FNR 2015-12-31 as vehicle_individual_id15 import db/KJORETOY_DRIVSTOFF_OMK 2015-12-31 as fuel_type15 assign-labels fuel_type15 fuel_type_txt tabulate fuel_type15, missing piechart fuel_type15 // Assign vehicles to emission categories (approach Gray vs. Green) generate emission_categories_gray_green15 = fuel_type15 replace emission_categories_gray_green15 = 'Green' if emission_categories_gray_green15 == '05' replace emission_categories_gray_green15 = 'Gray' if emission_categories_gray_green15 == '01' | emission_categories_gray_green15 == '02' | emission_categories_gray_green15 == '03' | emission_categories_gray_green15 == '04' | emission_categories_gray_green15 == '07' | emission_categories_gray_green15 == '08' | emission_categories_gray_green15 == '09' | emission_categories_gray_green15 == '10' | emission_categories_gray_green15 == '11' | emission_categories_gray_green15 == '12' | emission_categories_gray_green15 == '13' | emission_categories_gray_green15 == '15' drop if emission_categories_gray_green15 == '06' // Tag vehicles by the numerical value of 0 (false) and 1 (true) within each emission category. generate vehicle_green15 = 0 replace vehicle_green15 = 1 if emission_categories_gray_green15 == 'Green' generate vehicle_gray15 = 0 replace vehicle_gray15 = 1 if emission_categories_gray_green15 == 'Gray' piechart emission_categories_gray_green15 tabulate emission_categories_gray_green15, missing //tabulate vehicle_green15 vehicle_gray15, missing // Make temporary clones of vehicle_DS_passenger for further analysis of the year 2015. clone-dataset vehicle_DS_passenger15 vehicle_DS_passenger_green_owned15 clone-dataset vehicle_DS_passenger15 vehicle_DS_passenger_gray_owned15 // Make temporary datasets to calculate categories of passenger vehicles per household in 2015. clone-dataset person_DS_Y15 household_DS_all_fuel_owners15 clone-dataset person_DS_Y15 household_DS_green_owners15 clone-dataset person_DS_Y15 household_DS_gray_owners15 textblock ::::: Owned private vehicles in Norway by Fuel Type in 2015. endblock // Step: At this step, passenger vehicles per person are calculated – irrespective of fuel type in 2015. collapse(count) fuel_type15, by(vehicle_individual_id15) rename fuel_type15 owned_vehicle_all_per_person15 //tabulate owned_vehicle_all_per_person15, missing merge owned_vehicle_all_per_person15 into household_DS_all_fuel_owners15 on household_id15 delete-dataset vehicle_DS_passenger15 // Then, aggregate the number of all categories of passenger vehicles per household in 2015. use household_DS_all_fuel_owners15 collapse(sum) owned_vehicle_all_per_person15, by(household_id15) rename owned_vehicle_all_per_person15 owned_vehicle_all_per_household15 //tabulate owned_vehicle_all_per_household15, missing histogram owned_vehicle_all_per_household15 if owned_vehicle_all_per_household15 > 0, freq //piechart owned_vehicle_all_per_household15 if owned_vehicle_all_per_household15 > 0 piechart owned_vehicle_all_per_household15 merge owned_vehicle_all_per_household15 into household_DS_all on PERSONID_1 delete-dataset household_DS_all_fuel_owners15 // Step: Sum the number of green vehicles per person in 2015. use vehicle_DS_passenger_green_owned15 collapse(sum) vehicle_green15, by(vehicle_individual_id15) rename vehicle_green15 owned_vehicle_green_per_person15 //tabulate owned_vehicle_green_per_person15, missing merge owned_vehicle_green_per_person15 into household_DS_green_owners15 on household_id15 delete-dataset vehicle_DS_passenger_green_owned15 // Then, aggregate the number of green vehicles per household in 2015. use household_DS_green_owners15 collapse(sum) owned_vehicle_green_per_person15, by(household_id15) rename owned_vehicle_green_per_person15 owned_vehicle_green_per_household15 //tabulate owned_vehicle_green_per_household15, missing histogram owned_vehicle_green_per_household15 if owned_vehicle_green_per_household15 > 0, freq piechart owned_vehicle_green_per_household15 if owned_vehicle_green_per_household15 > 0 piechart owned_vehicle_green_per_household15 // Merge green vehicle ownership data into the main dataset merge owned_vehicle_green_per_household15 into household_DS_all on PERSONID_1 delete-dataset household_DS_green_owners15 // Step: Sum the number of gray vehicles per person in 2015. use vehicle_DS_passenger_gray_owned15 collapse(sum) vehicle_gray15, by(vehicle_individual_id15) rename vehicle_gray15 owned_vehicle_gray_per_person15 //tabulate owned_vehicle_gray_per_person15, missing merge owned_vehicle_gray_per_person15 into household_DS_gray_owners15 on household_id15 delete-dataset vehicle_DS_passenger_gray_owned15 // Then, aggregate the number of gray vehicles per household in 2015. use household_DS_gray_owners15 collapse(sum) owned_vehicle_gray_per_person15, by(household_id15) rename owned_vehicle_gray_per_person15 owned_vehicle_gray_per_household15 merge owned_vehicle_gray_per_household15 into household_DS_all on PERSONID_1 delete-dataset household_DS_gray_owners15 // Vehicles 2016 create-dataset vehicle_DS_passenger16 import db/KJORETOY_KJT_GRUP 2016-12-31 as vehicle_group_code16 keep if vehicle_group_code16 == '101' // keep only passenger cars (also no ambulances) // To find individuals owning passenger vehicles in Norway, vehicles are linked to people using KJORETOY_KJORETOYID_FNR. import db/KJORETOY_KJORETOYID_FNR 2016-12-31 as vehicle_individual_id16 import db/KJORETOY_DRIVSTOFF_OMK 2016-12-31 as fuel_type16 assign-labels fuel_type16 fuel_type_txt tabulate fuel_type16, missing piechart fuel_type16 // Assign vehicles to emission categories (approach Gray vs. Green) generate emission_categories_gray_green16 = fuel_type16 replace emission_categories_gray_green16 = 'Green' if emission_categories_gray_green16 == '05' replace emission_categories_gray_green16 = 'Gray' if emission_categories_gray_green16 == '01' | emission_categories_gray_green16 == '02' | emission_categories_gray_green16 == '03' | emission_categories_gray_green16 == '04' | emission_categories_gray_green16 == '07' | emission_categories_gray_green16 == '08' | emission_categories_gray_green16 == '09' | emission_categories_gray_green16 == '10' | emission_categories_gray_green16 == '11' | emission_categories_gray_green16 == '12' | emission_categories_gray_green16 == '13' | emission_categories_gray_green16 == '15' drop if emission_categories_gray_green16 == '06' // Tag vehicles by the numerical value of 0 (false) and 1 (true) within each emission category. generate vehicle_green16 = 0 replace vehicle_green16 = 1 if emission_categories_gray_green16 == 'Green' generate vehicle_gray16 = 0 replace vehicle_gray16 = 1 if emission_categories_gray_green16 == 'Gray' piechart emission_categories_gray_green16 tabulate emission_categories_gray_green16, missing //tabulate vehicle_green16 vehicle_gray16, missing // Make temporary clones of vehicle_DS_passenger for further analysis of the year 2016. clone-dataset vehicle_DS_passenger16 vehicle_DS_passenger_green_owned16 clone-dataset vehicle_DS_passenger16 vehicle_DS_passenger_gray_owned16 // Make temporary datasets to calculate categories of passenger vehicles per household in 2016. clone-dataset person_DS_Y16 household_DS_all_fuel_owners16 clone-dataset person_DS_Y16 household_DS_green_owners16 clone-dataset person_DS_Y16 household_DS_gray_owners16 textblock ::::: Owned private vehicles in Norway by Fuel Type in 2016. endblock // Step: At this step, passenger vehicles per person are calculated – irrespective of fuel type in 2016. collapse(count) fuel_type16, by(vehicle_individual_id16) rename fuel_type16 owned_vehicle_all_per_person16 //tabulate owned_vehicle_all_per_person16, missing merge owned_vehicle_all_per_person16 into household_DS_all_fuel_owners16 on household_id16 delete-dataset vehicle_DS_passenger16 // Then, aggregate the number of all categories of passenger vehicles per household in 2016. use household_DS_all_fuel_owners16 collapse(sum) owned_vehicle_all_per_person16, by(household_id16) rename owned_vehicle_all_per_person16 owned_vehicle_all_per_household16 //tabulate owned_vehicle_all_per_household16, missing histogram owned_vehicle_all_per_household16 if owned_vehicle_all_per_household16 > 0, freq //piechart owned_vehicle_all_per_household16 if owned_vehicle_all_per_household16 > 0 piechart owned_vehicle_all_per_household16 merge owned_vehicle_all_per_household16 into household_DS_all on PERSONID_1 delete-dataset household_DS_all_fuel_owners16 // Step: Sum the number of green vehicles per person in 2016. use vehicle_DS_passenger_green_owned16 collapse(sum) vehicle_green16, by(vehicle_individual_id16) rename vehicle_green16 owned_vehicle_green_per_person16 //tabulate owned_vehicle_green_per_person16, missing merge owned_vehicle_green_per_person16 into household_DS_green_owners16 on household_id16 delete-dataset vehicle_DS_passenger_green_owned16 // Then, aggregate the number of green vehicles per household in 2016. use household_DS_green_owners16 collapse(sum) owned_vehicle_green_per_person16, by(household_id16) rename owned_vehicle_green_per_person16 owned_vehicle_green_per_household16 //tabulate owned_vehicle_green_per_household16, missing histogram owned_vehicle_green_per_household16 if owned_vehicle_green_per_household16 > 0, freq piechart owned_vehicle_green_per_household16 if owned_vehicle_green_per_household16 > 0 piechart owned_vehicle_green_per_household16 // Merge green vehicle ownership data into the main dataset merge owned_vehicle_green_per_household16 into household_DS_all on PERSONID_1 delete-dataset household_DS_green_owners16 // Step: Sum the number of gray vehicles per person in 2016. use vehicle_DS_passenger_gray_owned16 collapse(sum) vehicle_gray16, by(vehicle_individual_id16) rename vehicle_gray16 owned_vehicle_gray_per_person16 //tabulate owned_vehicle_gray_per_person16, missing merge owned_vehicle_gray_per_person16 into household_DS_gray_owners16 on household_id16 delete-dataset vehicle_DS_passenger_gray_owned16 // Then, aggregate the number of gray vehicles per household in 2016. use household_DS_gray_owners16 collapse(sum) owned_vehicle_gray_per_person16, by(household_id16) rename owned_vehicle_gray_per_person16 owned_vehicle_gray_per_household16 merge owned_vehicle_gray_per_household16 into household_DS_all on PERSONID_1 delete-dataset household_DS_gray_owners16 // Vehicles 2017 create-dataset vehicle_DS_passenger17 import db/KJORETOY_KJT_GRUP 2017-12-31 as vehicle_group_code17 keep if vehicle_group_code17 == '101' // keep only passenger cars (also no ambulances) // To find individuals owning passenger vehicles in Norway, vehicles are linked to people using KJORETOY_KJORETOYID_FNR. import db/KJORETOY_KJORETOYID_FNR 2017-12-31 as vehicle_individual_id17 import db/KJORETOY_DRIVSTOFF_OMK 2017-12-31 as fuel_type17 assign-labels fuel_type17 fuel_type_txt tabulate fuel_type17, missing piechart fuel_type17 // Assign vehicles to emission categories (approach Gray vs. Green) generate emission_categories_gray_green17 = fuel_type17 replace emission_categories_gray_green17 = 'Green' if emission_categories_gray_green17 == '05' replace emission_categories_gray_green17 = 'Gray' if emission_categories_gray_green17 == '01' | emission_categories_gray_green17 == '02' | emission_categories_gray_green17 == '03' | emission_categories_gray_green17 == '04' | emission_categories_gray_green17 == '07' | emission_categories_gray_green17 == '08' | emission_categories_gray_green17 == '09' | emission_categories_gray_green17 == '10' | emission_categories_gray_green17 == '11' | emission_categories_gray_green17 == '12' | emission_categories_gray_green17 == '13' | emission_categories_gray_green17 == '15' drop if emission_categories_gray_green17 == '06' // Tag vehicles by the numerical value of 0 (false) and 1 (true) within each emission category. generate vehicle_green17 = 0 replace vehicle_green17 = 1 if emission_categories_gray_green17 == 'Green' generate vehicle_gray17 = 0 replace vehicle_gray17 = 1 if emission_categories_gray_green17 == 'Gray' piechart emission_categories_gray_green17 tabulate emission_categories_gray_green17, missing //tabulate vehicle_green17 vehicle_gray17, missing // Make temporary clones of vehicle_DS_passenger for further analysis of the year 2017. clone-dataset vehicle_DS_passenger17 vehicle_DS_passenger_green_owned17 clone-dataset vehicle_DS_passenger17 vehicle_DS_passenger_gray_owned17 // Make temporary datasets to calculate categories of passenger vehicles per household in 2017. clone-dataset person_DS_Y17 household_DS_all_fuel_owners17 clone-dataset person_DS_Y17 household_DS_green_owners17 clone-dataset person_DS_Y17 household_DS_gray_owners17 textblock ::::: Owned private vehicles in Norway by Fuel Type in 2017. endblock // Step: At this step, passenger vehicles per person are calculated – irrespective of fuel type in 2017. collapse(count) fuel_type17, by(vehicle_individual_id17) rename fuel_type17 owned_vehicle_all_per_person17 //tabulate owned_vehicle_all_per_person17, missing merge owned_vehicle_all_per_person17 into household_DS_all_fuel_owners17 on household_id17 delete-dataset vehicle_DS_passenger17 // Then, aggregate the number of all categories of passenger vehicles per household in 2017. use household_DS_all_fuel_owners17 collapse(sum) owned_vehicle_all_per_person17, by(household_id17) rename owned_vehicle_all_per_person17 owned_vehicle_all_per_household17 //tabulate owned_vehicle_all_per_household17, missing histogram owned_vehicle_all_per_household17 if owned_vehicle_all_per_household17 > 0, freq //piechart owned_vehicle_all_per_household17 if owned_vehicle_all_per_household17 > 0 piechart owned_vehicle_all_per_household17 merge owned_vehicle_all_per_household17 into household_DS_all on PERSONID_1 delete-dataset household_DS_all_fuel_owners17 // Step: Sum the number of green vehicles per person in 2017. use vehicle_DS_passenger_green_owned17 collapse(sum) vehicle_green17, by(vehicle_individual_id17) rename vehicle_green17 owned_vehicle_green_per_person17 //tabulate owned_vehicle_green_per_person17, missing merge owned_vehicle_green_per_person17 into household_DS_green_owners17 on household_id17 delete-dataset vehicle_DS_passenger_green_owned17 // Then, aggregate the number of green vehicles per household in 2017. use household_DS_green_owners17 collapse(sum) owned_vehicle_green_per_person17, by(household_id17) rename owned_vehicle_green_per_person17 owned_vehicle_green_per_household17 //tabulate owned_vehicle_green_per_household17, missing histogram owned_vehicle_green_per_household17 if owned_vehicle_green_per_household17 > 0, freq piechart owned_vehicle_green_per_household17 if owned_vehicle_green_per_household17 > 0 piechart owned_vehicle_green_per_household17 // Merge green vehicle ownership data into the main dataset merge owned_vehicle_green_per_household17 into household_DS_all on PERSONID_1 delete-dataset household_DS_green_owners17 // Step: Sum the number of gray vehicles per person in 2017. use vehicle_DS_passenger_gray_owned17 collapse(sum) vehicle_gray17, by(vehicle_individual_id17) rename vehicle_gray17 owned_vehicle_gray_per_person17 //tabulate owned_vehicle_gray_per_person17, missing merge owned_vehicle_gray_per_person17 into household_DS_gray_owners17 on household_id17 delete-dataset vehicle_DS_passenger_gray_owned17 // Then, aggregate the number of gray vehicles per household in 2017. use household_DS_gray_owners17 collapse(sum) owned_vehicle_gray_per_person17, by(household_id17) rename owned_vehicle_gray_per_person17 owned_vehicle_gray_per_household17 merge owned_vehicle_gray_per_household17 into household_DS_all on PERSONID_1 delete-dataset household_DS_gray_owners17 // Vehicles 2018 create-dataset vehicle_DS_passenger18 import db/KJORETOY_KJT_GRUP 2018-12-31 as vehicle_group_code18 keep if vehicle_group_code18 == '101' // keep only passenger cars (also no ambulances) // To find individuals owning passenger vehicles in Norway, vehicles are linked to people using KJORETOY_KJORETOYID_FNR. import db/KJORETOY_KJORETOYID_FNR 2018-12-31 as vehicle_individual_id18 import db/KJORETOY_DRIVSTOFF_OMK 2018-12-31 as fuel_type18 assign-labels fuel_type18 fuel_type_txt tabulate fuel_type18, missing piechart fuel_type18 // Assign vehicles to emission categories (approach Gray vs. Green) generate emission_categories_gray_green18 = fuel_type18 replace emission_categories_gray_green18 = 'Green' if emission_categories_gray_green18 == '05' replace emission_categories_gray_green18 = 'Gray' if emission_categories_gray_green18 == '01' | emission_categories_gray_green18 == '02' | emission_categories_gray_green18 == '03' | emission_categories_gray_green18 == '04' | emission_categories_gray_green18 == '07' | emission_categories_gray_green18 == '08' | emission_categories_gray_green18 == '09' | emission_categories_gray_green18 == '10' | emission_categories_gray_green18 == '11' | emission_categories_gray_green18 == '12' | emission_categories_gray_green18 == '13' | emission_categories_gray_green18 == '15' drop if emission_categories_gray_green18 == '06' // Tag vehicles by the numerical value of 0 (false) and 1 (true) within each emission category. generate vehicle_green18 = 0 replace vehicle_green18 = 1 if emission_categories_gray_green18 == 'Green' generate vehicle_gray18 = 0 replace vehicle_gray18 = 1 if emission_categories_gray_green18 == 'Gray' piechart emission_categories_gray_green18 tabulate emission_categories_gray_green18, missing //tabulate vehicle_green18 vehicle_gray18, missing // Make temporary clones of vehicle_DS_passenger for further analysis of the year 2018. clone-dataset vehicle_DS_passenger18 vehicle_DS_passenger_green_owned18 clone-dataset vehicle_DS_passenger18 vehicle_DS_passenger_gray_owned18 // Make temporary datasets to calculate categories of passenger vehicles per household in 2018. clone-dataset person_DS_Y18 household_DS_all_fuel_owners18 clone-dataset person_DS_Y18 household_DS_green_owners18 clone-dataset person_DS_Y18 household_DS_gray_owners18 textblock ::::: Owned private vehicles in Norway by Fuel Type in 2018. endblock // Step: At this step, passenger vehicles per person are calculated – irrespective of fuel type in 2018. collapse(count) fuel_type18, by(vehicle_individual_id18) rename fuel_type18 owned_vehicle_all_per_person18 //tabulate owned_vehicle_all_per_person18, missing merge owned_vehicle_all_per_person18 into household_DS_all_fuel_owners18 on household_id18 delete-dataset vehicle_DS_passenger18 // Then, aggregate the number of all categories of passenger vehicles per household in 2018. use household_DS_all_fuel_owners18 collapse(sum) owned_vehicle_all_per_person18, by(household_id18) rename owned_vehicle_all_per_person18 owned_vehicle_all_per_household18 //tabulate owned_vehicle_all_per_household18, missing histogram owned_vehicle_all_per_household18 if owned_vehicle_all_per_household18 > 0, freq //piechart owned_vehicle_all_per_household18 if owned_vehicle_all_per_household18 > 0 piechart owned_vehicle_all_per_household18 merge owned_vehicle_all_per_household18 into household_DS_all on PERSONID_1 delete-dataset household_DS_all_fuel_owners18 // Step: Sum the number of green vehicles per person in 2018. use vehicle_DS_passenger_green_owned18 collapse(sum) vehicle_green18, by(vehicle_individual_id18) rename vehicle_green18 owned_vehicle_green_per_person18 //tabulate owned_vehicle_green_per_person18, missing merge owned_vehicle_green_per_person18 into household_DS_green_owners18 on household_id18 delete-dataset vehicle_DS_passenger_green_owned18 // Then, aggregate the number of green vehicles per household in 2018. use household_DS_green_owners18 collapse(sum) owned_vehicle_green_per_person18, by(household_id18) rename owned_vehicle_green_per_person18 owned_vehicle_green_per_household18 //tabulate owned_vehicle_green_per_household18, missing histogram owned_vehicle_green_per_household18 if owned_vehicle_green_per_household18 > 0, freq piechart owned_vehicle_green_per_household18 if owned_vehicle_green_per_household18 > 0 piechart owned_vehicle_green_per_household18 // Merge green vehicle ownership data into the main dataset merge owned_vehicle_green_per_household18 into household_DS_all on PERSONID_1 delete-dataset household_DS_green_owners18 // Step: Sum the number of gray vehicles per person in 2018. use vehicle_DS_passenger_gray_owned18 collapse(sum) vehicle_gray18, by(vehicle_individual_id18) rename vehicle_gray18 owned_vehicle_gray_per_person18 //tabulate owned_vehicle_gray_per_person18, missing merge owned_vehicle_gray_per_person18 into household_DS_gray_owners18 on household_id18 delete-dataset vehicle_DS_passenger_gray_owned18 // Then, aggregate the number of gray vehicles per household in 2018. use household_DS_gray_owners18 collapse(sum) owned_vehicle_gray_per_person18, by(household_id18) rename owned_vehicle_gray_per_person18 owned_vehicle_gray_per_household18 merge owned_vehicle_gray_per_household18 into household_DS_all on PERSONID_1 delete-dataset household_DS_gray_owners18 // Vehicles 2019 create-dataset vehicle_DS_passenger19 import db/KJORETOY_KJT_GRUP 2019-12-31 as vehicle_group_code19 keep if vehicle_group_code19 == '101' // keep only passenger cars (also no ambulances) // To find individuals owning passenger vehicles in Norway, vehicles are linked to people using KJORETOY_KJORETOYID_FNR. import db/KJORETOY_KJORETOYID_FNR 2019-12-31 as vehicle_individual_id19 import db/KJORETOY_DRIVSTOFF_OMK 2019-12-31 as fuel_type19 assign-labels fuel_type19 fuel_type_txt tabulate fuel_type19, missing piechart fuel_type19 // Assign vehicles to emission categories (approach Gray vs. Green) generate emission_categories_gray_green19 = fuel_type19 replace emission_categories_gray_green19 = 'Green' if emission_categories_gray_green19 == '05' replace emission_categories_gray_green19 = 'Gray' if emission_categories_gray_green19 == '01' | emission_categories_gray_green19 == '02' | emission_categories_gray_green19 == '03' | emission_categories_gray_green19 == '04' | emission_categories_gray_green19 == '07' | emission_categories_gray_green19 == '08' | emission_categories_gray_green19 == '09' | emission_categories_gray_green19 == '10' | emission_categories_gray_green19 == '11' | emission_categories_gray_green19 == '12' | emission_categories_gray_green19 == '13' | emission_categories_gray_green19 == '15' drop if emission_categories_gray_green19 == '06' // Tag vehicles by the numerical value of 0 (false) and 1 (true) within each emission category. generate vehicle_green19 = 0 replace vehicle_green19 = 1 if emission_categories_gray_green19 == 'Green' generate vehicle_gray19 = 0 replace vehicle_gray19 = 1 if emission_categories_gray_green19 == 'Gray' piechart emission_categories_gray_green19 tabulate emission_categories_gray_green19, missing //tabulate vehicle_green19 vehicle_gray19, missing // Make temporary clones of vehicle_DS_passenger for further analysis of the year 2019. clone-dataset vehicle_DS_passenger19 vehicle_DS_passenger_green_owned19 clone-dataset vehicle_DS_passenger19 vehicle_DS_passenger_gray_owned19 // Make temporary datasets to calculate categories of passenger vehicles per household in 2019. clone-dataset person_DS_Y19 household_DS_all_fuel_owners19 clone-dataset person_DS_Y19 household_DS_green_owners19 clone-dataset person_DS_Y19 household_DS_gray_owners19 textblock ::::: Owned private vehicles in Norway by Fuel Type in 2019. endblock // Step: At this step, passenger vehicles per person are calculated – irrespective of fuel type in 2019. collapse(count) fuel_type19, by(vehicle_individual_id19) rename fuel_type19 owned_vehicle_all_per_person19 //tabulate owned_vehicle_all_per_person19, missing merge owned_vehicle_all_per_person19 into household_DS_all_fuel_owners19 on household_id19 delete-dataset vehicle_DS_passenger19 // Then, aggregate the number of all categories of passenger vehicles per household in 2019. use household_DS_all_fuel_owners19 collapse(sum) owned_vehicle_all_per_person19, by(household_id19) rename owned_vehicle_all_per_person19 owned_vehicle_all_per_household19 //tabulate owned_vehicle_all_per_household19, missing histogram owned_vehicle_all_per_household19 if owned_vehicle_all_per_household19 > 0, freq //piechart owned_vehicle_all_per_household19 if owned_vehicle_all_per_household19 > 0 piechart owned_vehicle_all_per_household19 merge owned_vehicle_all_per_household19 into household_DS_all on PERSONID_1 delete-dataset household_DS_all_fuel_owners19 // Step: Sum the number of green vehicles per person in 2019. use vehicle_DS_passenger_green_owned19 collapse(sum) vehicle_green19, by(vehicle_individual_id19) rename vehicle_green19 owned_vehicle_green_per_person19 //tabulate owned_vehicle_green_per_person19, missing merge owned_vehicle_green_per_person19 into household_DS_green_owners19 on household_id19 delete-dataset vehicle_DS_passenger_green_owned19 // Then, aggregate the number of green vehicles per household in 2019. use household_DS_green_owners19 collapse(sum) owned_vehicle_green_per_person19, by(household_id19) rename owned_vehicle_green_per_person19 owned_vehicle_green_per_household19 //tabulate owned_vehicle_green_per_household19, missing histogram owned_vehicle_green_per_household19 if owned_vehicle_green_per_household19 > 0, freq piechart owned_vehicle_green_per_household19 if owned_vehicle_green_per_household19 > 0 piechart owned_vehicle_green_per_household19 // Merge green vehicle ownership data into the main dataset merge owned_vehicle_green_per_household19 into household_DS_all on PERSONID_1 delete-dataset household_DS_green_owners19 // Step: Sum the number of gray vehicles per person in 2019. use vehicle_DS_passenger_gray_owned19 collapse(sum) vehicle_gray19, by(vehicle_individual_id19) rename vehicle_gray19 owned_vehicle_gray_per_person19 //tabulate owned_vehicle_gray_per_person19, missing merge owned_vehicle_gray_per_person19 into household_DS_gray_owners19 on household_id19 delete-dataset vehicle_DS_passenger_gray_owned19 // Then, aggregate the number of gray vehicles per household in 2019. use household_DS_gray_owners19 collapse(sum) owned_vehicle_gray_per_person19, by(household_id19) rename owned_vehicle_gray_per_person19 owned_vehicle_gray_per_household19 merge owned_vehicle_gray_per_household19 into household_DS_all on PERSONID_1 delete-dataset household_DS_gray_owners19 // Vehicles 2020 create-dataset vehicle_DS_passenger20 import db/KJORETOY_KJT_GRUP 2020-12-31 as vehicle_group_code20 keep if vehicle_group_code20 == '101' // keep only passenger cars (also no ambulances) // To find individuals owning passenger vehicles in Norway, vehicles are linked to people using KJORETOY_KJORETOYID_FNR. import db/KJORETOY_KJORETOYID_FNR 2020-12-31 as vehicle_individual_id20 import db/KJORETOY_DRIVSTOFF_OMK 2020-12-31 as fuel_type20 assign-labels fuel_type20 fuel_type_txt tabulate fuel_type20, missing piechart fuel_type20 // Assign vehicles to emission categories (approach Gray vs. Green) generate emission_categories_gray_green20 = fuel_type20 replace emission_categories_gray_green20 = 'Green' if emission_categories_gray_green20 == '05' replace emission_categories_gray_green20 = 'Gray' if emission_categories_gray_green20 == '01' | emission_categories_gray_green20 == '02' | emission_categories_gray_green20 == '03' | emission_categories_gray_green20 == '04' | emission_categories_gray_green20 == '07' | emission_categories_gray_green20 == '08' | emission_categories_gray_green20 == '09' | emission_categories_gray_green20 == '10' | emission_categories_gray_green20 == '11' | emission_categories_gray_green20 == '12' | emission_categories_gray_green20 == '13' | emission_categories_gray_green20 == '15' drop if emission_categories_gray_green20 == '06' // Tag vehicles by the numerical value of 0 (false) and 1 (true) within each emission category. generate vehicle_green20 = 0 replace vehicle_green20 = 1 if emission_categories_gray_green20 == 'Green' generate vehicle_gray20 = 0 replace vehicle_gray20 = 1 if emission_categories_gray_green20 == 'Gray' piechart emission_categories_gray_green20 tabulate emission_categories_gray_green20, missing //tabulate vehicle_green20 vehicle_gray20, missing // Make temporary clones of vehicle_DS_passenger for further analysis of the year 2020. clone-dataset vehicle_DS_passenger20 vehicle_DS_passenger_green_owned20 clone-dataset vehicle_DS_passenger20 vehicle_DS_passenger_gray_owned20 // Make temporary datasets to calculate categories of passenger vehicles per household in 2020. clone-dataset person_DS_Y20 household_DS_all_fuel_owners20 clone-dataset person_DS_Y20 household_DS_green_owners20 clone-dataset person_DS_Y20 household_DS_gray_owners20 textblock ::::: Owned private vehicles in Norway by Fuel Type in 2020. endblock // Step: At this step, passenger vehicles per person are calculated – irrespective of fuel type in 2020. collapse(count) fuel_type20, by(vehicle_individual_id20) rename fuel_type20 owned_vehicle_all_per_person20 //tabulate owned_vehicle_all_per_person20, missing merge owned_vehicle_all_per_person20 into household_DS_all_fuel_owners20 on household_id20 delete-dataset vehicle_DS_passenger20 // Then, aggregate the number of all categories of passenger vehicles per household in 2020. use household_DS_all_fuel_owners20 collapse(sum) owned_vehicle_all_per_person20, by(household_id20) rename owned_vehicle_all_per_person20 owned_vehicle_all_per_household20 //tabulate owned_vehicle_all_per_household20, missing histogram owned_vehicle_all_per_household20 if owned_vehicle_all_per_household20 > 0, freq //piechart owned_vehicle_all_per_household20 if owned_vehicle_all_per_household20 > 0 piechart owned_vehicle_all_per_household20 merge owned_vehicle_all_per_household20 into household_DS_all on PERSONID_1 delete-dataset household_DS_all_fuel_owners20 // Step: Sum the number of green vehicles per person in 2020. use vehicle_DS_passenger_green_owned20 collapse(sum) vehicle_green20, by(vehicle_individual_id20) rename vehicle_green20 owned_vehicle_green_per_person20 //tabulate owned_vehicle_green_per_person20, missing merge owned_vehicle_green_per_person20 into household_DS_green_owners20 on household_id20 delete-dataset vehicle_DS_passenger_green_owned20 // Then, aggregate the number of green vehicles per household in 2020. use household_DS_green_owners20 collapse(sum) owned_vehicle_green_per_person20, by(household_id20) rename owned_vehicle_green_per_person20 owned_vehicle_green_per_household20 //tabulate owned_vehicle_green_per_household20, missing histogram owned_vehicle_green_per_household20 if owned_vehicle_green_per_household20 > 0, freq piechart owned_vehicle_green_per_household20 if owned_vehicle_green_per_household20 > 0 piechart owned_vehicle_green_per_household20 // Merge green vehicle ownership data into the main dataset merge owned_vehicle_green_per_household20 into household_DS_all on PERSONID_1 delete-dataset household_DS_green_owners20 // Step: Sum the number of gray vehicles per person in 2020. use vehicle_DS_passenger_gray_owned20 collapse(sum) vehicle_gray20, by(vehicle_individual_id20) rename vehicle_gray20 owned_vehicle_gray_per_person20 //tabulate owned_vehicle_gray_per_person20, missing merge owned_vehicle_gray_per_person20 into household_DS_gray_owners20 on household_id20 delete-dataset vehicle_DS_passenger_gray_owned20 // Then, aggregate the number of gray vehicles per household in 2020. use household_DS_gray_owners20 collapse(sum) owned_vehicle_gray_per_person20, by(household_id20) rename owned_vehicle_gray_per_person20 owned_vehicle_gray_per_household20 merge owned_vehicle_gray_per_household20 into household_DS_all on PERSONID_1 delete-dataset household_DS_gray_owners20 // Vehicles 2021 create-dataset vehicle_DS_passenger21 import db/KJORETOY_KJT_GRUP 2021-12-31 as vehicle_group_code21 keep if vehicle_group_code21 == '101' // keep only passenger cars (also no ambulances) // To find individuals owning passenger vehicles in Norway, vehicles are linked to people using KJORETOY_KJORETOYID_FNR. import db/KJORETOY_KJORETOYID_FNR 2021-12-31 as vehicle_individual_id21 import db/KJORETOY_DRIVSTOFF_OMK 2021-12-31 as fuel_type21 assign-labels fuel_type21 fuel_type_txt tabulate fuel_type21, missing piechart fuel_type21 // Assign vehicles to emission categories (approach Gray vs. Green) generate emission_categories_gray_green21 = fuel_type21 replace emission_categories_gray_green21 = 'Green' if emission_categories_gray_green21 == '05' replace emission_categories_gray_green21 = 'Gray' if emission_categories_gray_green21 == '01' | emission_categories_gray_green21 == '02' | emission_categories_gray_green21 == '03' | emission_categories_gray_green21 == '04' | emission_categories_gray_green21 == '07' | emission_categories_gray_green21 == '08' | emission_categories_gray_green21 == '09' | emission_categories_gray_green21 == '10' | emission_categories_gray_green21 == '11' | emission_categories_gray_green21 == '12' | emission_categories_gray_green21 == '13' | emission_categories_gray_green21 == '15' drop if emission_categories_gray_green21 == '06' // Tag vehicles by the numerical value of 0 (false) and 1 (true) within each emission category. generate vehicle_green21 = 0 replace vehicle_green21 = 1 if emission_categories_gray_green21 == 'Green' generate vehicle_gray21 = 0 replace vehicle_gray21 = 1 if emission_categories_gray_green21 == 'Gray' piechart emission_categories_gray_green21 tabulate emission_categories_gray_green21, missing //tabulate vehicle_green21 vehicle_gray21, missing // Make temporary clones of vehicle_DS_passenger for further analysis of the year 2021. clone-dataset vehicle_DS_passenger21 vehicle_DS_passenger_green_owned21 clone-dataset vehicle_DS_passenger21 vehicle_DS_passenger_gray_owned21 // Make temporary datasets to calculate categories of passenger vehicles per household in 2021. clone-dataset person_DS_Y21 household_DS_all_fuel_owners21 clone-dataset person_DS_Y21 household_DS_green_owners21 clone-dataset person_DS_Y21 household_DS_gray_owners21 textblock ::::: Owned private vehicles in Norway by Fuel Type in 2021. endblock // Step: At this step, passenger vehicles per person are calculated – irrespective of fuel type in 2021. collapse(count) fuel_type21, by(vehicle_individual_id21) rename fuel_type21 owned_vehicle_all_per_person21 //tabulate owned_vehicle_all_per_person21, missing merge owned_vehicle_all_per_person21 into household_DS_all_fuel_owners21 on household_id21 delete-dataset vehicle_DS_passenger21 // Then, aggregate the number of all categories of passenger vehicles per household in 2021. use household_DS_all_fuel_owners21 collapse(sum) owned_vehicle_all_per_person21, by(household_id21) rename owned_vehicle_all_per_person21 owned_vehicle_all_per_household21 //tabulate owned_vehicle_all_per_household21, missing histogram owned_vehicle_all_per_household21 if owned_vehicle_all_per_household21 > 0, freq //piechart owned_vehicle_all_per_household21 if owned_vehicle_all_per_household21 > 0 piechart owned_vehicle_all_per_household21 merge owned_vehicle_all_per_household21 into household_DS_all on PERSONID_1 delete-dataset household_DS_all_fuel_owners21 // Step: Sum the number of green vehicles per person in 2021. use vehicle_DS_passenger_green_owned21 collapse(sum) vehicle_green21, by(vehicle_individual_id21) rename vehicle_green21 owned_vehicle_green_per_person21 //tabulate owned_vehicle_green_per_person21, missing merge owned_vehicle_green_per_person21 into household_DS_green_owners21 on household_id21 delete-dataset vehicle_DS_passenger_green_owned21 // Then, aggregate the number of green vehicles per household in 2021. use household_DS_green_owners21 collapse(sum) owned_vehicle_green_per_person21, by(household_id21) rename owned_vehicle_green_per_person21 owned_vehicle_green_per_household21 //tabulate owned_vehicle_green_per_household21, missing histogram owned_vehicle_green_per_household21 if owned_vehicle_green_per_household21 > 0, freq piechart owned_vehicle_green_per_household21 if owned_vehicle_green_per_household21 > 0 piechart owned_vehicle_green_per_household21 // Merge green vehicle ownership data into the main dataset merge owned_vehicle_green_per_household21 into household_DS_all on PERSONID_1 delete-dataset household_DS_green_owners21 // Step: Sum the number of gray vehicles per person in 2021. use vehicle_DS_passenger_gray_owned21 collapse(sum) vehicle_gray21, by(vehicle_individual_id21) rename vehicle_gray21 owned_vehicle_gray_per_person21 //tabulate owned_vehicle_gray_per_person21, missing merge owned_vehicle_gray_per_person21 into household_DS_gray_owners21 on household_id21 delete-dataset vehicle_DS_passenger_gray_owned21 // Then, aggregate the number of gray vehicles per household in 2021. use household_DS_gray_owners21 collapse(sum) owned_vehicle_gray_per_person21, by(household_id21) rename owned_vehicle_gray_per_person21 owned_vehicle_gray_per_household21 merge owned_vehicle_gray_per_household21 into household_DS_all on PERSONID_1 delete-dataset household_DS_gray_owners21 // Vehicles 2022 create-dataset vehicle_DS_passenger22 import db/KJORETOY_KJT_GRUP 2022-12-31 as vehicle_group_code22 keep if vehicle_group_code22 == '101' // keep only passenger cars (also no ambulances) // To find individuals owning passenger vehicles in Norway, vehicles are linked to people using KJORETOY_KJORETOYID_FNR. import db/KJORETOY_KJORETOYID_FNR 2022-12-31 as vehicle_individual_id22 import db/KJORETOY_DRIVSTOFF_OMK 2022-12-31 as fuel_type22 assign-labels fuel_type22 fuel_type_txt tabulate fuel_type22, missing piechart fuel_type22 // Assign vehicles to emission categories (approach Gray vs. Green) generate emission_categories_gray_green22 = fuel_type22 replace emission_categories_gray_green22 = 'Green' if emission_categories_gray_green22 == '05' replace emission_categories_gray_green22 = 'Gray' if emission_categories_gray_green22 == '01' | emission_categories_gray_green22 == '02' | emission_categories_gray_green22 == '03' | emission_categories_gray_green22 == '04' | emission_categories_gray_green22 == '07' | emission_categories_gray_green22 == '08' | emission_categories_gray_green22 == '09' | emission_categories_gray_green22 == '10' | emission_categories_gray_green22 == '11' | emission_categories_gray_green22 == '12' | emission_categories_gray_green22 == '13' | emission_categories_gray_green22 == '15' drop if emission_categories_gray_green22 == '06' // Tag vehicles by the numerical value of 0 (false) and 1 (true) within each emission category. generate vehicle_green22 = 0 replace vehicle_green22 = 1 if emission_categories_gray_green22 == 'Green' generate vehicle_gray22 = 0 replace vehicle_gray22 = 1 if emission_categories_gray_green22 == 'Gray' piechart emission_categories_gray_green22 tabulate emission_categories_gray_green22, missing //tabulate vehicle_green22 vehicle_gray22, missing // Make temporary clones of vehicle_DS_passenger for further analysis of the year 2022. clone-dataset vehicle_DS_passenger22 vehicle_DS_passenger_green_owned22 clone-dataset vehicle_DS_passenger22 vehicle_DS_passenger_gray_owned22 // Make temporary datasets to calculate categories of passenger vehicles per household in 2022. clone-dataset person_DS_Y22 household_DS_all_fuel_owners22 clone-dataset person_DS_Y22 household_DS_green_owners22 clone-dataset person_DS_Y22 household_DS_gray_owners22 textblock ::::: Owned private vehicles in Norway by Fuel Type in 2022. endblock // Step: At this step, passenger vehicles per person are calculated – irrespective of fuel type in 2022. collapse(count) fuel_type22, by(vehicle_individual_id22) rename fuel_type22 owned_vehicle_all_per_person22 //tabulate owned_vehicle_all_per_person22, missing merge owned_vehicle_all_per_person22 into household_DS_all_fuel_owners22 on household_id22 delete-dataset vehicle_DS_passenger22 // Then, aggregate the number of all categories of passenger vehicles per household in 2022. use household_DS_all_fuel_owners22 collapse(sum) owned_vehicle_all_per_person22, by(household_id22) rename owned_vehicle_all_per_person22 owned_vehicle_all_per_household22 //tabulate owned_vehicle_all_per_household22, missing histogram owned_vehicle_all_per_household22 if owned_vehicle_all_per_household22 > 0, freq //piechart owned_vehicle_all_per_household22 if owned_vehicle_all_per_household22 > 0 piechart owned_vehicle_all_per_household22 merge owned_vehicle_all_per_household22 into household_DS_all on PERSONID_1 delete-dataset household_DS_all_fuel_owners22 // Step: Sum the number of green vehicles per person in 2022. use vehicle_DS_passenger_green_owned22 collapse(sum) vehicle_green22, by(vehicle_individual_id22) rename vehicle_green22 owned_vehicle_green_per_person22 //tabulate owned_vehicle_green_per_person22, missing merge owned_vehicle_green_per_person22 into household_DS_green_owners22 on household_id22 delete-dataset vehicle_DS_passenger_green_owned22 // Then, aggregate the number of green vehicles per household in 2022. use household_DS_green_owners22 collapse(sum) owned_vehicle_green_per_person22, by(household_id22) rename owned_vehicle_green_per_person22 owned_vehicle_green_per_household22 //tabulate owned_vehicle_green_per_household22, missing histogram owned_vehicle_green_per_household22 if owned_vehicle_green_per_household22 > 0, freq piechart owned_vehicle_green_per_household22 if owned_vehicle_green_per_household22 > 0 piechart owned_vehicle_green_per_household22 // Merge green vehicle ownership data into the main dataset merge owned_vehicle_green_per_household22 into household_DS_all on PERSONID_1 delete-dataset household_DS_green_owners22 // Step: Sum the number of gray vehicles per person in 2022. use vehicle_DS_passenger_gray_owned22 collapse(sum) vehicle_gray22, by(vehicle_individual_id22) rename vehicle_gray22 owned_vehicle_gray_per_person22 //tabulate owned_vehicle_gray_per_person22, missing merge owned_vehicle_gray_per_person22 into household_DS_gray_owners22 on household_id22 delete-dataset vehicle_DS_passenger_gray_owned22 // Then, aggregate the number of gray vehicles per household in 2022. use household_DS_gray_owners22 collapse(sum) owned_vehicle_gray_per_person22, by(household_id22) rename owned_vehicle_gray_per_person22 owned_vehicle_gray_per_household22 merge owned_vehicle_gray_per_household22 into household_DS_all on PERSONID_1 delete-dataset household_DS_gray_owners22 //Streamlining of the dataset: Keep only those households who at least once owned one vehicle over the time period... use household_DS_all keep if owned_vehicle_all_per_household05 >= 1 | owned_vehicle_all_per_household06 >= 1 | owned_vehicle_all_per_household07 >= 1 | owned_vehicle_all_per_household08 >= 1 | owned_vehicle_all_per_household09 >= 1 | owned_vehicle_all_per_household10 >= 1 | owned_vehicle_all_per_household11 >= 1 | owned_vehicle_all_per_household12 >= 1 | owned_vehicle_all_per_household13 >= 1 | owned_vehicle_all_per_household14 >= 1 | owned_vehicle_all_per_household15 >= 1 | owned_vehicle_all_per_household16 >= 1 | owned_vehicle_all_per_household17 >= 1 | owned_vehicle_all_per_household18 >= 1 | owned_vehicle_all_per_household19 >= 1 | owned_vehicle_all_per_household20 >= 1 | owned_vehicle_all_per_household21 >= 1 | owned_vehicle_all_per_household22 >= 1 // From this step, we only call information of those households with a record of vehicle ownership // 2005 'International Background' vs. 'Local Background' clone-dataset person_DS_Y05 immigration_category_DS05 use immigration_category_DS05 import db/BEFOLKNING_INVKAT as immigration_category05 // This variable shows various combinations of own or parents' country of birth. define-labels immigration_category_txt 'A' 'Born in Norway with two Norwegian-born parents' 'B' 'Immigrants' 'C' 'Norwegian-born with immigrant parents' 'E' 'Foreign-born with one Norwegian-born parent' 'F' 'Norwegian-born with one foreign-born parent' 'G' 'Foreign-born with two Norwegian-born parents' assign-labels immigration_category05 immigration_category_txt piechart immigration_category05 tabulate immigration_category05, missing generate person_background05 = 0 replace person_background05 = 1 if immigration_category05 == 'B' | immigration_category05 == 'C' | immigration_category05 == 'E' | immigration_category05 == 'F' | sysmiss(immigration_category05) // 1 if any 'International Background', 0 if 'Local Background' piechart person_background05 collapse(sum) person_background05, by(household_id05) generate household_background05 = 0 replace household_background05 = 1 if person_background05 >= 1 piechart household_background05 //summarize household_background05 merge household_background05 into household_DS_all on PERSONID_1 delete-dataset immigration_category_DS05 // 2006 'International Background' vs. 'Local Background' clone-dataset person_DS_Y06 immigration_category_DS06 use immigration_category_DS06 import db/BEFOLKNING_INVKAT as immigration_category06 // This variable shows various combinations of own or parents' country of birth. assign-labels immigration_category06 immigration_category_txt piechart immigration_category06 tabulate immigration_category06, missing generate person_background06 = 0 replace person_background06 = 1 if immigration_category06 == 'B' | immigration_category06 == 'C' | immigration_category06 == 'E' | immigration_category06 == 'F' | sysmiss(immigration_category06) // 1 if any 'International Background', 0 if 'Local Background' piechart person_background06 collapse(sum) person_background06, by(household_id06) generate household_background06 = 0 replace household_background06 = 1 if person_background06 >= 1 piechart household_background06 //summarize household_background06 merge household_background06 into household_DS_all on PERSONID_1 delete-dataset immigration_category_DS06 // 2007 'International Background' vs. 'Local Background' clone-dataset person_DS_Y07 immigration_category_DS07 use immigration_category_DS07 import db/BEFOLKNING_INVKAT as immigration_category07 // This variable shows various combinations of own or parents' country of birth. assign-labels immigration_category07 immigration_category_txt piechart immigration_category07 tabulate immigration_category07, missing generate person_background07 = 0 replace person_background07 = 1 if immigration_category07 == 'B' | immigration_category07 == 'C' | immigration_category07 == 'E' | immigration_category07 == 'F' | sysmiss(immigration_category07) // 1 if any 'International Background', 0 if 'Local Background' piechart person_background07 collapse(sum) person_background07, by(household_id07) generate household_background07 = 0 replace household_background07 = 1 if person_background07 >= 1 piechart household_background07 //summarize household_background07 merge household_background07 into household_DS_all on PERSONID_1 delete-dataset immigration_category_DS07 // 2008 'International Background' vs. 'Local Background' clone-dataset person_DS_Y08 immigration_category_DS08 use immigration_category_DS08 import db/BEFOLKNING_INVKAT as immigration_category08 // This variable shows various combinations of own or parents' country of birth. assign-labels immigration_category08 immigration_category_txt piechart immigration_category08 tabulate immigration_category08, missing generate person_background08 = 0 replace person_background08 = 1 if immigration_category08 == 'B' | immigration_category08 == 'C' | immigration_category08 == 'E' | immigration_category08 == 'F' | sysmiss(immigration_category08) // 1 if any 'International Background', 0 if 'Local Background' piechart person_background08 collapse(sum) person_background08, by(household_id08) generate household_background08 = 0 replace household_background08 = 1 if person_background08 >= 1 piechart household_background08 //summarize household_background08 merge household_background08 into household_DS_all on PERSONID_1 delete-dataset immigration_category_DS08 // 2009 'International Background' vs. 'Local Background' clone-dataset person_DS_Y09 immigration_category_DS09 use immigration_category_DS09 import db/BEFOLKNING_INVKAT as immigration_category09 // This variable shows various combinations of own or parents' country of birth. assign-labels immigration_category09 immigration_category_txt piechart immigration_category09 tabulate immigration_category09, missing generate person_background09 = 0 replace person_background09 = 1 if immigration_category09 == 'B' | immigration_category09 == 'C' | immigration_category09 == 'E' | immigration_category09 == 'F' | sysmiss(immigration_category09) // 1 if any 'International Background', 0 if 'Local Background' piechart person_background09 collapse(sum) person_background09, by(household_id09) generate household_background09 = 0 replace household_background09 = 1 if person_background09 >= 1 piechart household_background09 //summarize household_background09 merge household_background09 into household_DS_all on PERSONID_1 delete-dataset immigration_category_DS09 // 2010 'International Background' vs. 'Local Background' clone-dataset person_DS_Y10 immigration_category_DS10 use immigration_category_DS10 import db/BEFOLKNING_INVKAT as immigration_category10 // This variable shows various combinations of own or parents' country of birth. assign-labels immigration_category10 immigration_category_txt piechart immigration_category10 tabulate immigration_category10, missing generate person_background10 = 0 replace person_background10 = 1 if immigration_category10 == 'B' | immigration_category10 == 'C' | immigration_category10 == 'E' | immigration_category10 == 'F' | sysmiss(immigration_category10) // 1 if any 'International Background', 0 if 'Local Background' piechart person_background10 collapse(sum) person_background10, by(household_id10) generate household_background10 = 0 replace household_background10 = 1 if person_background10 >= 1 piechart household_background10 //summarize household_background10 merge household_background10 into household_DS_all on PERSONID_1 delete-dataset immigration_category_DS10 // 2011 'International Background' vs. 'Local Background' clone-dataset person_DS_Y11 immigration_category_DS11 use immigration_category_DS11 import db/BEFOLKNING_INVKAT as immigration_category11 // This variable shows various combinations of own or parents' country of birth. assign-labels immigration_category11 immigration_category_txt piechart immigration_category11 tabulate immigration_category11, missing generate person_background11 = 0 replace person_background11 = 1 if immigration_category11 == 'B' | immigration_category11 == 'C' | immigration_category11 == 'E' | immigration_category11 == 'F' | sysmiss(immigration_category11) // 1 if any 'International Background', 0 if 'Local Background' piechart person_background11 collapse(sum) person_background11, by(household_id11) generate household_background11 = 0 replace household_background11 = 1 if person_background11 >= 1 piechart household_background11 //summarize household_background11 merge household_background11 into household_DS_all on PERSONID_1 delete-dataset immigration_category_DS11 // 2012 'International Background' vs. 'Local Background' clone-dataset person_DS_Y12 immigration_category_DS12 use immigration_category_DS12 import db/BEFOLKNING_INVKAT as immigration_category12 // This variable shows various combinations of own or parents' country of birth. assign-labels immigration_category12 immigration_category_txt piechart immigration_category12 tabulate immigration_category12, missing generate person_background12 = 0 replace person_background12 = 1 if immigration_category12 == 'B' | immigration_category12 == 'C' | immigration_category12 == 'E' | immigration_category12 == 'F' | sysmiss(immigration_category12) // 1 if any 'International Background', 0 if 'Local Background' piechart person_background12 collapse(sum) person_background12, by(household_id12) generate household_background12 = 0 replace household_background12 = 1 if person_background12 >= 1 piechart household_background12 //summarize household_background12 merge household_background12 into household_DS_all on PERSONID_1 delete-dataset immigration_category_DS12 // 2013 'International Background' vs. 'Local Background' clone-dataset person_DS_Y13 immigration_category_DS13 use immigration_category_DS13 import db/BEFOLKNING_INVKAT as immigration_category13 // This variable shows various combinations of own or parents' country of birth. assign-labels immigration_category13 immigration_category_txt piechart immigration_category13 tabulate immigration_category13, missing generate person_background13 = 0 replace person_background13 = 1 if immigration_category13 == 'B' | immigration_category13 == 'C' | immigration_category13 == 'E' | immigration_category13 == 'F' | sysmiss(immigration_category13) // 1 if any 'International Background', 0 if 'Local Background' piechart person_background13 collapse(sum) person_background13, by(household_id13) generate household_background13 = 0 replace household_background13 = 1 if person_background13 >= 1 piechart household_background13 //summarize household_background13 merge household_background13 into household_DS_all on PERSONID_1 delete-dataset immigration_category_DS13 // 2014 'International Background' vs. 'Local Background' clone-dataset person_DS_Y14 immigration_category_DS14 use immigration_category_DS14 import db/BEFOLKNING_INVKAT as immigration_category14 // This variable shows various combinations of own or parents' country of birth. assign-labels immigration_category14 immigration_category_txt piechart immigration_category14 tabulate immigration_category14, missing generate person_background14 = 0 replace person_background14 = 1 if immigration_category14 == 'B' | immigration_category14 == 'C' | immigration_category14 == 'E' | immigration_category14 == 'F' | sysmiss(immigration_category14) // 1 if any 'International Background', 0 if 'Local Background' piechart person_background14 collapse(sum) person_background14, by(household_id14) generate household_background14 = 0 replace household_background14 = 1 if person_background14 >= 1 piechart household_background14 //summarize household_background14 merge household_background14 into household_DS_all on PERSONID_1 delete-dataset immigration_category_DS14 // 2015 'International Background' vs. 'Local Background' clone-dataset person_DS_Y15 immigration_category_DS15 use immigration_category_DS15 import db/BEFOLKNING_INVKAT as immigration_category15 // This variable shows various combinations of own or parents' country of birth. assign-labels immigration_category15 immigration_category_txt piechart immigration_category15 tabulate immigration_category15, missing generate person_background15 = 0 replace person_background15 = 1 if immigration_category15 == 'B' | immigration_category15 == 'C' | immigration_category15 == 'E' | immigration_category15 == 'F' | sysmiss(immigration_category15) // 1 if any 'International Background', 0 if 'Local Background' piechart person_background15 collapse(sum) person_background15, by(household_id15) generate household_background15 = 0 replace household_background15 = 1 if person_background15 >= 1 piechart household_background15 //summarize household_background15 merge household_background15 into household_DS_all on PERSONID_1 delete-dataset immigration_category_DS15 // 2016 'International Background' vs. 'Local Background' clone-dataset person_DS_Y16 immigration_category_DS16 use immigration_category_DS16 import db/BEFOLKNING_INVKAT as immigration_category16 // This variable shows various combinations of own or parents' country of birth. assign-labels immigration_category16 immigration_category_txt piechart immigration_category16 tabulate immigration_category16, missing generate person_background16 = 0 replace person_background16 = 1 if immigration_category16 == 'B' | immigration_category16 == 'C' | immigration_category16 == 'E' | immigration_category16 == 'F' | sysmiss(immigration_category16) // 1 if any 'International Background', 0 if 'Local Background' piechart person_background16 collapse(sum) person_background16, by(household_id16) generate household_background16 = 0 replace household_background16 = 1 if person_background16 >= 1 piechart household_background16 //summarize household_background16 merge household_background16 into household_DS_all on PERSONID_1 delete-dataset immigration_category_DS16 // 2017 'International Background' vs. 'Local Background' clone-dataset person_DS_Y17 immigration_category_DS17 use immigration_category_DS17 import db/BEFOLKNING_INVKAT as immigration_category17 // This variable shows various combinations of own or parents' country of birth. assign-labels immigration_category17 immigration_category_txt piechart immigration_category17 tabulate immigration_category17, missing generate person_background17 = 0 replace person_background17 = 1 if immigration_category17 == 'B' | immigration_category17 == 'C' | immigration_category17 == 'E' | immigration_category17 == 'F' | sysmiss(immigration_category17) // 1 if any 'International Background', 0 if 'Local Background' piechart person_background17 collapse(sum) person_background17, by(household_id17) generate household_background17 = 0 replace household_background17 = 1 if person_background17 >= 1 piechart household_background17 //summarize household_background17 merge household_background17 into household_DS_all on PERSONID_1 delete-dataset immigration_category_DS17 // 2018 'International Background' vs. 'Local Background' clone-dataset person_DS_Y18 immigration_category_DS18 use immigration_category_DS18 import db/BEFOLKNING_INVKAT as immigration_category18 // This variable shows various combinations of own or parents' country of birth. assign-labels immigration_category18 immigration_category_txt piechart immigration_category18 tabulate immigration_category18, missing generate person_background18 = 0 replace person_background18 = 1 if immigration_category18 == 'B' | immigration_category18 == 'C' | immigration_category18 == 'E' | immigration_category18 == 'F' | sysmiss(immigration_category18) // 1 if any 'International Background', 0 if 'Local Background' piechart person_background18 collapse(sum) person_background18, by(household_id18) generate household_background18 = 0 replace household_background18 = 1 if person_background18 >= 1 piechart household_background18 //summarize household_background18 merge household_background18 into household_DS_all on PERSONID_1 delete-dataset immigration_category_DS18 // 2019 'International Background' vs. 'Local Background' clone-dataset person_DS_Y19 immigration_category_DS19 use immigration_category_DS19 import db/BEFOLKNING_INVKAT as immigration_category19 // This variable shows various combinations of own or parents' country of birth. assign-labels immigration_category19 immigration_category_txt piechart immigration_category19 tabulate immigration_category19, missing generate person_background19 = 0 replace person_background19 = 1 if immigration_category19 == 'B' | immigration_category19 == 'C' | immigration_category19 == 'E' | immigration_category19 == 'F' | sysmiss(immigration_category19) // 1 if any 'International Background', 0 if 'Local Background' piechart person_background19 collapse(sum) person_background19, by(household_id19) generate household_background19 = 0 replace household_background19 = 1 if person_background19 >= 1 piechart household_background19 //summarize household_background19 merge household_background19 into household_DS_all on PERSONID_1 delete-dataset immigration_category_DS19 // 2020 'International Background' vs. 'Local Background' clone-dataset person_DS_Y20 immigration_category_DS20 use immigration_category_DS20 import db/BEFOLKNING_INVKAT as immigration_category20 // This variable shows various combinations of own or parents' country of birth. assign-labels immigration_category20 immigration_category_txt piechart immigration_category20 tabulate immigration_category20, missing generate person_background20 = 0 replace person_background20 = 1 if immigration_category20 == 'B' | immigration_category20 == 'C' | immigration_category20 == 'E' | immigration_category20 == 'F' | sysmiss(immigration_category20) // 1 if any 'International Background', 0 if 'Local Background' piechart person_background20 collapse(sum) person_background20, by(household_id20) generate household_background20 = 0 replace household_background20 = 1 if person_background20 >= 1 piechart household_background20 //summarize household_background20 merge household_background20 into household_DS_all on PERSONID_1 delete-dataset immigration_category_DS20 // 2021 'International Background' vs. 'Local Background' clone-dataset person_DS_Y21 immigration_category_DS21 use immigration_category_DS21 import db/BEFOLKNING_INVKAT as immigration_category21 // This variable shows various combinations of own or parents' country of birth. assign-labels immigration_category21 immigration_category_txt piechart immigration_category21 tabulate immigration_category21, missing generate person_background21 = 0 replace person_background21 = 1 if immigration_category21 == 'B' | immigration_category21 == 'C' | immigration_category21 == 'E' | immigration_category21 == 'F' | sysmiss(immigration_category21) // 1 if any 'International Background', 0 if 'Local Background' piechart person_background21 collapse(sum) person_background21, by(household_id21) generate household_background21 = 0 replace household_background21 = 1 if person_background21 >= 1 piechart household_background21 //summarize household_background21 merge household_background21 into household_DS_all on PERSONID_1 delete-dataset immigration_category_DS21 // 2022 'International Background' vs. 'Local Background' clone-dataset person_DS_Y22 immigration_category_DS22 use immigration_category_DS22 import db/BEFOLKNING_INVKAT as immigration_category22 // This variable shows various combinations of own or parents' country of birth. assign-labels immigration_category22 immigration_category_txt piechart immigration_category22 tabulate immigration_category22, missing generate person_background22 = 0 replace person_background22 = 1 if immigration_category22 == 'B' | immigration_category22 == 'C' | immigration_category22 == 'E' | immigration_category22 == 'F' | sysmiss(immigration_category22) // 1 if any 'International Background', 0 if 'Local Background' piechart person_background22 collapse(sum) person_background22, by(household_id22) generate household_background22 = 0 replace household_background22 = 1 if person_background22 >= 1 piechart household_background22 //summarize household_background22 merge household_background22 into household_DS_all on PERSONID_1 delete-dataset immigration_category_DS22 textblock Finding people who work in a municipality other than the residence municipality (dummy =1) ----------- ::::: All Norway We know that those under 18 and retired are the people with the most missing values in work. The following procedure helps to identify those who actually work, but in a different municipality than the one they are formally registered. EFOLKNING_KOMMNR_FORMELL (379 categories): This variable shows the person's municipality of residence according to the population register (formal address). as of YYYY.01.01. This is a "Status" variable. REGSYS_ARBKOMM (443 categories, from 2000 to 2014): This variable indicates the municipality where the enterprise in which a person works is located. This applies to the main employment relationship (it is mainly the employment relationship with the highest agreed working hours). The variable includes residents aged 15-74 who are employed, main employment in November. Observations with the values 0 and unstated (missing) are omitted. REGSYS_ARB_ARBKOMM (379 categories, from 2015 to 2022): This variable indicates the municipality where the business in which a person works is located. Applies to the main employment relationship (it is essentially the employment relationship with the highest agreed working hours). as of YYYY.11.16. This is a "Status" variable. The variable includes residents aged 15-74 who are employed. Observations with the values 0 and unstated (missing) are omitted. #Note the registration date differences! endblock // Examples to limit to specific municipalities: //keep if person_residence_municipality20 == '0301' // Oslo //keep if person_residence_municipality20 == '5001' // Trondheim // Find individual persons who worked in a municipality other than the residence municipality (=1) in 2005. clone-dataset person_DS_Y05 household_DS_municipality05 use household_DS_municipality05 import db/BEFOLKNING_KOMMNR_FORMELL 2005-01-01 as person_residence_municipality05 import db/REGSYS_ARBKOMM 2005-11-16 as person_work_municipality05 tabulate person_residence_municipality05, missing tabulate person_work_municipality05, missing generate person_residence_work05 = 1 replace person_residence_work05 = 0 if person_residence_municipality05 == person_work_municipality05 | sysmiss(person_residence_municipality05) | sysmiss(person_work_municipality05) tabulate person_residence_work05, missing // Find households with at least one member who worked in a municipality other than the residence municipality (=1) in 2005. collapse(sum) person_residence_work05, by(household_id05) generate household_residence_work05 = 0 replace household_residence_work05 = 1 if person_residence_work05 >= 1 piechart household_residence_work05 tabulate household_residence_work05 merge household_residence_work05 into household_DS_all on PERSONID_1 delete-dataset household_DS_municipality05 // Find individual persons who worked in a municipality other than the residence municipality (=1) in 2006. clone-dataset person_DS_Y06 household_DS_municipality06 use household_DS_municipality06 import db/BEFOLKNING_KOMMNR_FORMELL 2006-01-01 as person_residence_municipality06 import db/REGSYS_ARBKOMM 2006-11-16 as person_work_municipality06 //tabulate person_residence_municipality06, missing //tabulate person_work_municipality06, missing generate person_residence_work06 = 1 replace person_residence_work06 = 0 if person_residence_municipality06 == person_work_municipality06 | sysmiss(person_residence_municipality06) | sysmiss(person_work_municipality06) tabulate person_residence_work06, missing // Find households with at least one member who worked in a municipality other than the residence municipality (=1) in 2006. collapse(sum) person_residence_work06, by(household_id06) generate household_residence_work06 = 0 replace household_residence_work06 = 1 if person_residence_work06 >= 1 piechart household_residence_work06 tabulate household_residence_work06 merge household_residence_work06 into household_DS_all on PERSONID_1 delete-dataset household_DS_municipality06 // Find individual persons who worked in a municipality other than the residence municipality (=1) in 2007. clone-dataset person_DS_Y07 household_DS_municipality07 use household_DS_municipality07 import db/BEFOLKNING_KOMMNR_FORMELL 2007-01-01 as person_residence_municipality07 import db/REGSYS_ARBKOMM 2007-11-16 as person_work_municipality07 //tabulate person_residence_municipality07, missing //tabulate person_work_municipality07, missing generate person_residence_work07 = 1 replace person_residence_work07 = 0 if person_residence_municipality07 == person_work_municipality07 | sysmiss(person_residence_municipality07) | sysmiss(person_work_municipality07) tabulate person_residence_work07, missing // Find households with at least one member who worked in a municipality other than the residence municipality (=1) in 2007. collapse(sum) person_residence_work07, by(household_id07) generate household_residence_work07 = 0 replace household_residence_work07 = 1 if person_residence_work07 >= 1 piechart household_residence_work07 tabulate household_residence_work07 merge household_residence_work07 into household_DS_all on PERSONID_1 delete-dataset household_DS_municipality07 // Find individual persons who worked in a municipality other than the residence municipality (=1) in 2008. clone-dataset person_DS_Y08 household_DS_municipality08 use household_DS_municipality08 import db/BEFOLKNING_KOMMNR_FORMELL 2008-01-01 as person_residence_municipality08 import db/REGSYS_ARBKOMM 2008-11-16 as person_work_municipality08 //tabulate person_residence_municipality08, missing //tabulate person_work_municipality08, missing generate person_residence_work08 = 1 replace person_residence_work08 = 0 if person_residence_municipality08 == person_work_municipality08 | sysmiss(person_residence_municipality08) | sysmiss(person_work_municipality08) tabulate person_residence_work08, missing // Find households with at least one member who worked in a municipality other than the residence municipality (=1) in 2008. collapse(sum) person_residence_work08, by(household_id08) generate household_residence_work08 = 0 replace household_residence_work08 = 1 if person_residence_work08 >= 1 piechart household_residence_work08 tabulate household_residence_work08 merge household_residence_work08 into household_DS_all on PERSONID_1 delete-dataset household_DS_municipality08 // Find individual persons who worked in a municipality other than the residence municipality (=1) in 2009. clone-dataset person_DS_Y09 household_DS_municipality09 use household_DS_municipality09 import db/BEFOLKNING_KOMMNR_FORMELL 2009-01-01 as person_residence_municipality09 import db/REGSYS_ARBKOMM 2009-11-16 as person_work_municipality09 //tabulate person_residence_municipality09, missing //tabulate person_work_municipality09, missing generate person_residence_work09 = 1 replace person_residence_work09 = 0 if person_residence_municipality09 == person_work_municipality09 | sysmiss(person_residence_municipality09) | sysmiss(person_work_municipality09) tabulate person_residence_work09, missing // Find households with at least one member who worked in a municipality other than the residence municipality (=1) in 2009. collapse(sum) person_residence_work09, by(household_id09) generate household_residence_work09 = 0 replace household_residence_work09 = 1 if person_residence_work09 >= 1 piechart household_residence_work09 tabulate household_residence_work09 merge household_residence_work09 into household_DS_all on PERSONID_1 delete-dataset household_DS_municipality09 // Find individual persons who worked in a municipality other than the residence municipality (=1) in 2010. clone-dataset person_DS_Y10 household_DS_municipality10 use household_DS_municipality10 import db/BEFOLKNING_KOMMNR_FORMELL 2010-01-01 as person_residence_municipality10 import db/REGSYS_ARBKOMM 2010-11-16 as person_work_municipality10 //tabulate person_residence_municipality10, missing //tabulate person_work_municipality10, missing generate person_residence_work10 = 1 replace person_residence_work10 = 0 if person_residence_municipality10 == person_work_municipality10 | sysmiss(person_residence_municipality10) | sysmiss(person_work_municipality10) tabulate person_residence_work10, missing // Find households with at least one member who worked in a municipality other than the residence municipality (=1) in 2010. collapse(sum) person_residence_work10, by(household_id10) generate household_residence_work10 = 0 replace household_residence_work10 = 1 if person_residence_work10 >= 1 piechart household_residence_work10 tabulate household_residence_work10 merge household_residence_work10 into household_DS_all on PERSONID_1 delete-dataset household_DS_municipality10 // Find individual persons who worked in a municipality other than the residence municipality (=1) in 2011. clone-dataset person_DS_Y11 household_DS_municipality11 use household_DS_municipality11 import db/BEFOLKNING_KOMMNR_FORMELL 2011-01-01 as person_residence_municipality11 import db/REGSYS_ARBKOMM 2011-11-16 as person_work_municipality11 //tabulate person_residence_municipality11, missing //tabulate person_work_municipality11, missing generate person_residence_work11 = 1 replace person_residence_work11 = 0 if person_residence_municipality11 == person_work_municipality11 | sysmiss(person_residence_municipality11) | sysmiss(person_work_municipality11) tabulate person_residence_work11, missing // Find households with at least one member who worked in a municipality other than the residence municipality (=1) in 2011. collapse(sum) person_residence_work11, by(household_id11) generate household_residence_work11 = 0 replace household_residence_work11 = 1 if person_residence_work11 >= 1 piechart household_residence_work11 tabulate household_residence_work11 merge household_residence_work11 into household_DS_all on PERSONID_1 delete-dataset household_DS_municipality11 // Find individual persons who worked in a municipality other than the residence municipality (=1) in 2012. clone-dataset person_DS_Y12 household_DS_municipality12 use household_DS_municipality12 import db/BEFOLKNING_KOMMNR_FORMELL 2012-01-01 as person_residence_municipality12 import db/REGSYS_ARBKOMM 2012-11-16 as person_work_municipality12 //tabulate person_residence_municipality12, missing //tabulate person_work_municipality12, missing generate person_residence_work12 = 1 replace person_residence_work12 = 0 if person_residence_municipality12 == person_work_municipality12 | sysmiss(person_residence_municipality12) | sysmiss(person_work_municipality12) tabulate person_residence_work12, missing // Find households with at least one member who worked in a municipality other than the residence municipality (=1) in 2012. collapse(sum) person_residence_work12, by(household_id12) generate household_residence_work12 = 0 replace household_residence_work12 = 1 if person_residence_work12 >= 1 piechart household_residence_work12 tabulate household_residence_work12 merge household_residence_work12 into household_DS_all on PERSONID_1 delete-dataset household_DS_municipality12 // Find individual persons who worked in a municipality other than the residence municipality (=1) in 2013. clone-dataset person_DS_Y13 household_DS_municipality13 use household_DS_municipality13 import db/BEFOLKNING_KOMMNR_FORMELL 2013-01-01 as person_residence_municipality13 import db/REGSYS_ARBKOMM 2013-11-16 as person_work_municipality13 //tabulate person_residence_municipality13, missing //tabulate person_work_municipality13, missing generate person_residence_work13 = 1 replace person_residence_work13 = 0 if person_residence_municipality13 == person_work_municipality13 | sysmiss(person_residence_municipality13) | sysmiss(person_work_municipality13) tabulate person_residence_work13, missing // Find households with at least one member who worked in a municipality other than the residence municipality (=1) in 2013. collapse(sum) person_residence_work13, by(household_id13) generate household_residence_work13 = 0 replace household_residence_work13 = 1 if person_residence_work13 >= 1 piechart household_residence_work13 tabulate household_residence_work13 merge household_residence_work13 into household_DS_all on PERSONID_1 delete-dataset household_DS_municipality13 // Find individual persons who worked in a municipality other than the residence municipality (=1) in 2014. clone-dataset person_DS_Y14 household_DS_municipality14 use household_DS_municipality14 import db/BEFOLKNING_KOMMNR_FORMELL 2014-01-01 as person_residence_municipality14 import db/REGSYS_ARBKOMM 2014-11-16 as person_work_municipality14 //tabulate person_residence_municipality14, missing //tabulate person_work_municipality14, missing generate person_residence_work14 = 1 replace person_residence_work14 = 0 if person_residence_municipality14 == person_work_municipality14 | sysmiss(person_residence_municipality14) | sysmiss(person_work_municipality14) tabulate person_residence_work14, missing // Find households with at least one member who worked in a municipality other than the residence municipality (=1) in 2014. collapse(sum) person_residence_work14, by(household_id14) generate household_residence_work14 = 0 replace household_residence_work14 = 1 if person_residence_work14 >= 1 piechart household_residence_work14 tabulate household_residence_work14 merge household_residence_work14 into household_DS_all on PERSONID_1 delete-dataset household_DS_municipality14 // Find individual persons who worked in a municipality other than the residence municipality (=1) in 2015. clone-dataset person_DS_Y15 household_DS_municipality15 use household_DS_municipality15 import db/BEFOLKNING_KOMMNR_FORMELL 2015-01-01 as person_residence_municipality15 import db/REGSYS_ARB_ARBKOMM 2015-11-16 as person_work_municipality15 //tabulate person_residence_municipality15, missing //tabulate person_work_municipality15, missing generate person_residence_work15 = 1 replace person_residence_work15 = 0 if person_residence_municipality15 == person_work_municipality15 | sysmiss(person_residence_municipality15) | sysmiss(person_work_municipality15) tabulate person_residence_work15, missing // Find households with at least one member who worked in a municipality other than the residence municipality (=1) in 2015. collapse(sum) person_residence_work15, by(household_id15) generate household_residence_work15 = 0 replace household_residence_work15 = 1 if person_residence_work15 >= 1 piechart household_residence_work15 tabulate household_residence_work15 merge household_residence_work15 into household_DS_all on PERSONID_1 delete-dataset household_DS_municipality15 // Find individual persons who worked in a municipality other than the residence municipality (=1) in 2016. clone-dataset person_DS_Y16 household_DS_municipality16 use household_DS_municipality16 import db/BEFOLKNING_KOMMNR_FORMELL 2016-01-01 as person_residence_municipality16 import db/REGSYS_ARB_ARBKOMM 2016-11-16 as person_work_municipality16 //tabulate person_residence_municipality16, missing //tabulate person_work_municipality16, missing generate person_residence_work16 = 1 replace person_residence_work16 = 0 if person_residence_municipality16 == person_work_municipality16 | sysmiss(person_residence_municipality16) | sysmiss(person_work_municipality16) tabulate person_residence_work16, missing // Find households with at least one member who worked in a municipality other than the residence municipality (=1) in 2016. collapse(sum) person_residence_work16, by(household_id16) generate household_residence_work16 = 0 replace household_residence_work16 = 1 if person_residence_work16 >= 1 piechart household_residence_work16 tabulate household_residence_work16 merge household_residence_work16 into household_DS_all on PERSONID_1 delete-dataset household_DS_municipality16 // Find individual persons who worked in a municipality other than the residence municipality (=1) in 2017. clone-dataset person_DS_Y17 household_DS_municipality17 use household_DS_municipality17 import db/BEFOLKNING_KOMMNR_FORMELL 2017-01-01 as person_residence_municipality17 import db/REGSYS_ARB_ARBKOMM 2017-11-16 as person_work_municipality17 //tabulate person_residence_municipality17, missing //tabulate person_work_municipality17, missing generate person_residence_work17 = 1 replace person_residence_work17 = 0 if person_residence_municipality17 == person_work_municipality17 | sysmiss(person_residence_municipality17) | sysmiss(person_work_municipality17) tabulate person_residence_work17, missing // Find households with at least one member who worked in a municipality other than the residence municipality (=1) in 2017. collapse(sum) person_residence_work17, by(household_id17) generate household_residence_work17 = 0 replace household_residence_work17 = 1 if person_residence_work17 >= 1 piechart household_residence_work17 tabulate household_residence_work17 merge household_residence_work17 into household_DS_all on PERSONID_1 delete-dataset household_DS_municipality17 // Find individual persons who worked in a municipality other than the residence municipality (=1) in 2018. clone-dataset person_DS_Y18 household_DS_municipality18 use household_DS_municipality18 import db/BEFOLKNING_KOMMNR_FORMELL 2018-01-01 as person_residence_municipality18 import db/REGSYS_ARB_ARBKOMM 2018-11-16 as person_work_municipality18 //tabulate person_residence_municipality18, missing //tabulate person_work_municipality18, missing generate person_residence_work18 = 1 replace person_residence_work18 = 0 if person_residence_municipality18 == person_work_municipality18 | sysmiss(person_residence_municipality18) | sysmiss(person_work_municipality18) tabulate person_residence_work18, missing // Find households with at least one member who worked in a municipality other than the residence municipality (=1) in 2018. collapse(sum) person_residence_work18, by(household_id18) generate household_residence_work18 = 0 replace household_residence_work18 = 1 if person_residence_work18 >= 1 piechart household_residence_work18 tabulate household_residence_work18 merge household_residence_work18 into household_DS_all on PERSONID_1 delete-dataset household_DS_municipality18 // Find individual persons who worked in a municipality other than the residence municipality (=1) in 2019. clone-dataset person_DS_Y19 household_DS_municipality19 use household_DS_municipality19 import db/BEFOLKNING_KOMMNR_FORMELL 2019-01-01 as person_residence_municipality19 import db/REGSYS_ARB_ARBKOMM 2019-11-16 as person_work_municipality19 //tabulate person_residence_municipality19, missing //tabulate person_work_municipality19, missing generate person_residence_work19 = 1 replace person_residence_work19 = 0 if person_residence_municipality19 == person_work_municipality19 | sysmiss(person_residence_municipality19) | sysmiss(person_work_municipality19) tabulate person_residence_work19, missing // Find households with at least one member who worked in a municipality other than the residence municipality (=1) in 2019. collapse(sum) person_residence_work19, by(household_id19) generate household_residence_work19 = 0 replace household_residence_work19 = 1 if person_residence_work19 >= 1 piechart household_residence_work19 tabulate household_residence_work19 merge household_residence_work19 into household_DS_all on PERSONID_1 delete-dataset household_DS_municipality19 // Find individual persons who worked in a municipality other than the residence municipality (=1) in 2020. clone-dataset person_DS_Y20 household_DS_municipality20 use household_DS_municipality20 import db/BEFOLKNING_KOMMNR_FORMELL 2020-01-01 as person_residence_municipality20 import db/REGSYS_ARB_ARBKOMM 2020-11-16 as person_work_municipality20 //tabulate person_residence_municipality20, missing //tabulate person_work_municipality20, missing generate person_residence_work20 = 1 replace person_residence_work20 = 0 if person_residence_municipality20 == person_work_municipality20 | sysmiss(person_residence_municipality20) | sysmiss(person_work_municipality20) tabulate person_residence_work20, missing // Find households with at least one member who worked in a municipality other than the residence municipality (=1) in 2020. collapse(sum) person_residence_work20, by(household_id20) generate household_residence_work20 = 0 replace household_residence_work20 = 1 if person_residence_work20 >= 1 piechart household_residence_work20 tabulate household_residence_work20 merge household_residence_work20 into household_DS_all on PERSONID_1 delete-dataset household_DS_municipality20 // Find individual persons who worked in a municipality other than the residence municipality (=1) in 2021. clone-dataset person_DS_Y21 household_DS_municipality21 use household_DS_municipality21 import db/BEFOLKNING_KOMMNR_FORMELL 2021-01-01 as person_residence_municipality21 import db/REGSYS_ARB_ARBKOMM 2021-11-16 as person_work_municipality21 //tabulate person_residence_municipality21, missing //tabulate person_work_municipality21, missing generate person_residence_work21 = 1 replace person_residence_work21 = 0 if person_residence_municipality21 == person_work_municipality21 | sysmiss(person_residence_municipality21) | sysmiss(person_work_municipality21) tabulate person_residence_work21, missing // Find households with at least one member who worked in a municipality other than the residence municipality (=1) in 2021. collapse(sum) person_residence_work21, by(household_id21) generate household_residence_work21 = 0 replace household_residence_work21 = 1 if person_residence_work21 >= 1 piechart household_residence_work21 tabulate household_residence_work21 merge household_residence_work21 into household_DS_all on PERSONID_1 delete-dataset household_DS_municipality21 // Find individual persons who worked in a municipality other than the residence municipality (=1) in 2022. clone-dataset person_DS_Y22 household_DS_municipality22 use household_DS_municipality22 import db/BEFOLKNING_KOMMNR_FORMELL 2022-01-01 as person_residence_municipality22 import db/REGSYS_ARB_ARBKOMM 2022-11-16 as person_work_municipality22 tabulate person_residence_municipality22, missing tabulate person_work_municipality22, missing generate person_residence_work22 = 1 replace person_residence_work22 = 0 if person_residence_municipality22 == person_work_municipality22 | sysmiss(person_residence_municipality22) | sysmiss(person_work_municipality22) tabulate person_residence_work22, missing // Find households with at least one member who worked in a municipality other than the residence municipality (=1) in 2022. collapse(sum) person_residence_work22, by(household_id22) generate household_residence_work22 = 0 replace household_residence_work22 = 1 if person_residence_work22 >= 1 piechart household_residence_work22 tabulate household_residence_work22 merge household_residence_work22 into household_DS_all on PERSONID_1 delete-dataset household_DS_municipality22 textblock Household Dataset: Income, wealth, and debt ------------------ ::::: Income, wealth, and debt of household members are called and then aggregated onto the household level at this step. - Note 1: The unit changes from individual to household. - Note 2: The descriptive analysis indicates that there are individuals (and households) with negative income! - Note 3: SSB has several income-related variables, including - but not limited to - capital income (kapitalinntekter "INNTEKT_WKAPINNT"), wage income (Lønnsinntekter "INNTEKT_WLONN"), occupational income (Yrkesinntekter "INNTEKT_WYRKINNT"), total income (samlet inntekt "INNTEKT_WSAMINNT"), income after tax (inntekt etter skatt "INNTEKT_WIES"), and gross income (bruttoinntekt "SKATT_BRUTTOINNTEKT"). We use income after tax in our analysis. endblock // Calculating household level income (unit type = household) in temporary datasets: From 2005 to 2022 clone-dataset person_DS_Y05 household_DS_income05 use household_DS_income05 import db/INNTEKT_WIES 2005-12-31 as income_household_member05 histogram income_household_member05, width(100000) freq // This command generates a histogram of income with a width of NOK 100'000. // The following four lines of codes reveal those individuals with negative incomes in the year of analysis. //histogram income_household_member05 if income_household_member05 <= 0, width(100000) freq //generate income_household_member_category_100k = int(income_household_member/100000) //histogram income_household_member_category_100k, width(1) freq //tabulate income_household_member_category_100k, missing // Aggregating income of individual household members onto the household level. collapse(sum) income_household_member05, by(household_id05) rename income_household_member05 household_income05 histogram household_income05, width(100000) freq // This command generates a histogram of income with a width of NOK 100'000. summarize household_income05 merge household_income05 into household_DS_all on PERSONID_1 delete-dataset household_DS_income05 // And the following years ... clone-dataset person_DS_Y06 household_DS_income06 use household_DS_income06 import db/INNTEKT_WIES 2006-12-31 as income_household_member06 collapse(sum) income_household_member06, by(household_id06) rename income_household_member06 household_income06 summarize household_income06 merge household_income06 into household_DS_all on PERSONID_1 delete-dataset household_DS_income06 clone-dataset person_DS_Y07 household_DS_income07 use household_DS_income07 import db/INNTEKT_WIES 2007-12-31 as income_household_member07 collapse(sum) income_household_member07, by(household_id07) rename income_household_member07 household_income07 summarize household_income07 merge household_income07 into household_DS_all on PERSONID_1 delete-dataset household_DS_income07 clone-dataset person_DS_Y08 household_DS_income08 use household_DS_income08 import db/INNTEKT_WIES 2008-12-31 as income_household_member08 collapse(sum) income_household_member08, by(household_id08) rename income_household_member08 household_income08 summarize household_income08 merge household_income08 into household_DS_all on PERSONID_1 delete-dataset household_DS_income08 clone-dataset person_DS_Y09 household_DS_income09 use household_DS_income09 import db/INNTEKT_WIES 2009-12-31 as income_household_member09 collapse(sum) income_household_member09, by(household_id09) rename income_household_member09 household_income09 summarize household_income09 merge household_income09 into household_DS_all on PERSONID_1 delete-dataset household_DS_income09 clone-dataset person_DS_Y10 household_DS_income10 use household_DS_income10 import db/INNTEKT_WIES 2010-12-31 as income_household_member10 collapse(sum) income_household_member10, by(household_id10) rename income_household_member10 household_income10 summarize household_income10 merge household_income10 into household_DS_all on PERSONID_1 delete-dataset household_DS_income10 clone-dataset person_DS_Y11 household_DS_income11 use household_DS_income11 import db/INNTEKT_WIES 2011-12-31 as income_household_member11 collapse(sum) income_household_member11, by(household_id11) rename income_household_member11 household_income11 summarize household_income11 merge household_income11 into household_DS_all on PERSONID_1 delete-dataset household_DS_income11 clone-dataset person_DS_Y12 household_DS_income12 use household_DS_income12 import db/INNTEKT_WIES 2012-12-31 as income_household_member12 collapse(sum) income_household_member12, by(household_id12) rename income_household_member12 household_income12 summarize household_income12 merge household_income12 into household_DS_all on PERSONID_1 delete-dataset household_DS_income12 clone-dataset person_DS_Y13 household_DS_income13 use household_DS_income13 import db/INNTEKT_WIES 2013-12-31 as income_household_member13 collapse(sum) income_household_member13, by(household_id13) rename income_household_member13 household_income13 summarize household_income13 merge household_income13 into household_DS_all on PERSONID_1 delete-dataset household_DS_income13 clone-dataset person_DS_Y14 household_DS_income14 use household_DS_income14 import db/INNTEKT_WIES 2014-12-31 as income_household_member14 collapse(sum) income_household_member14, by(household_id14) rename income_household_member14 household_income14 summarize household_income14 merge household_income14 into household_DS_all on PERSONID_1 delete-dataset household_DS_income14 clone-dataset person_DS_Y15 household_DS_income15 use household_DS_income15 import db/INNTEKT_WIES 2015-12-31 as income_household_member15 collapse(sum) income_household_member15, by(household_id15) rename income_household_member15 household_income15 summarize household_income15 merge household_income15 into household_DS_all on PERSONID_1 delete-dataset household_DS_income15 clone-dataset person_DS_Y16 household_DS_income16 use household_DS_income16 import db/INNTEKT_WIES 2016-12-31 as income_household_member16 collapse(sum) income_household_member16, by(household_id16) rename income_household_member16 household_income16 summarize household_income16 merge household_income16 into household_DS_all on PERSONID_1 delete-dataset household_DS_income16 clone-dataset person_DS_Y17 household_DS_income17 use household_DS_income17 import db/INNTEKT_WIES 2017-12-31 as income_household_member17 collapse(sum) income_household_member17, by(household_id17) rename income_household_member17 household_income17 summarize household_income17 merge household_income17 into household_DS_all on PERSONID_1 delete-dataset household_DS_income17 clone-dataset person_DS_Y18 household_DS_income18 use household_DS_income18 import db/INNTEKT_WIES 2018-12-31 as income_household_member18 collapse(sum) income_household_member18, by(household_id18) rename income_household_member18 household_income18 summarize household_income18 merge household_income18 into household_DS_all on PERSONID_1 delete-dataset household_DS_income18 clone-dataset person_DS_Y19 household_DS_income19 use household_DS_income19 import db/INNTEKT_WIES 2019-12-31 as income_household_member19 collapse(sum) income_household_member19, by(household_id19) rename income_household_member19 household_income19 summarize household_income19 merge household_income19 into household_DS_all on PERSONID_1 delete-dataset household_DS_income19 clone-dataset person_DS_Y20 household_DS_income20 use household_DS_income20 import db/INNTEKT_WIES 2020-12-31 as income_household_member20 collapse(sum) income_household_member20, by(household_id20) rename income_household_member20 household_income20 summarize household_income20 merge household_income20 into household_DS_all on PERSONID_1 delete-dataset household_DS_income20 clone-dataset person_DS_Y21 household_DS_income21 use household_DS_income21 import db/INNTEKT_WIES 2021-12-31 as income_household_member21 collapse(sum) income_household_member21, by(household_id21) rename income_household_member21 household_income21 summarize household_income21 histogram household_income21, width(100000) freq merge household_income21 into household_DS_all on PERSONID_1 summarize household_income21 if household_income21 <= 0 delete-dataset household_DS_income21 // Calculating household level wealth (unit type = household) in temporary datasets: From 2005 to 2020 ... // #Note that Wealth data for 2021 is not available in database v26 clone-dataset person_DS_Y05 household_DS_wealth05 use household_DS_wealth05 import db/INNTEKT_BRUTTOFORM 2005-12-31 as wealth_household_member05 // This variable is the gross taxable wealth of individual persons. There are two other similar variables, "taxable gross assets SKATT_BRUTTOFORMUE", and "taxable gross financial capital SKATT_BRUTTO_FINANSKAPITAL" in SSB's data set. We use gross taxable wealth in our analysis. collapse(sum) wealth_household_member05, by(household_id05) rename wealth_household_member05 household_wealth05 merge household_wealth05 into household_DS_all on PERSONID_1 delete-dataset household_DS_wealth05 clone-dataset person_DS_Y06 household_DS_wealth06 use household_DS_wealth06 import db/INNTEKT_BRUTTOFORM 2006-12-31 as wealth_household_member06 collapse(sum) wealth_household_member06, by(household_id06) rename wealth_household_member06 household_wealth06 merge household_wealth06 into household_DS_all on PERSONID_1 delete-dataset household_DS_wealth06 clone-dataset person_DS_Y07 household_DS_wealth07 use household_DS_wealth07 import db/INNTEKT_BRUTTOFORM 2007-12-31 as wealth_household_member07 collapse(sum) wealth_household_member07, by(household_id07) rename wealth_household_member07 household_wealth07 merge household_wealth07 into household_DS_all on PERSONID_1 delete-dataset household_DS_wealth07 clone-dataset person_DS_Y08 household_DS_wealth08 use household_DS_wealth08 import db/INNTEKT_BRUTTOFORM 2008-12-31 as wealth_household_member08 collapse(sum) wealth_household_member08, by(household_id08) rename wealth_household_member08 household_wealth08 merge household_wealth08 into household_DS_all on PERSONID_1 delete-dataset household_DS_wealth08 clone-dataset person_DS_Y09 household_DS_wealth09 use household_DS_wealth09 import db/INNTEKT_BRUTTOFORM 2009-12-31 as wealth_household_member09 collapse(sum) wealth_household_member09, by(household_id09) rename wealth_household_member09 household_wealth09 merge household_wealth09 into household_DS_all on PERSONID_1 delete-dataset household_DS_wealth09 clone-dataset person_DS_Y10 household_DS_wealth10 use household_DS_wealth10 import db/INNTEKT_BRUTTOFORM 2010-12-31 as wealth_household_member10 collapse(sum) wealth_household_member10, by(household_id10) rename wealth_household_member10 household_wealth10 merge household_wealth10 into household_DS_all on PERSONID_1 delete-dataset household_DS_wealth10 clone-dataset person_DS_Y11 household_DS_wealth11 use household_DS_wealth11 import db/INNTEKT_BRUTTOFORM 2011-12-31 as wealth_household_member11 collapse(sum) wealth_household_member11, by(household_id11) rename wealth_household_member11 household_wealth11 merge household_wealth11 into household_DS_all on PERSONID_1 delete-dataset household_DS_wealth11 clone-dataset person_DS_Y12 household_DS_wealth12 use household_DS_wealth12 import db/INNTEKT_BRUTTOFORM 2012-12-31 as wealth_household_member12 collapse(sum) wealth_household_member12, by(household_id12) rename wealth_household_member12 household_wealth12 merge household_wealth12 into household_DS_all on PERSONID_1 delete-dataset household_DS_wealth12 clone-dataset person_DS_Y13 household_DS_wealth13 use household_DS_wealth13 import db/INNTEKT_BRUTTOFORM 2013-12-31 as wealth_household_member13 collapse(sum) wealth_household_member13, by(household_id13) rename wealth_household_member13 household_wealth13 merge household_wealth13 into household_DS_all on PERSONID_1 delete-dataset household_DS_wealth13 clone-dataset person_DS_Y14 household_DS_wealth14 use household_DS_wealth14 import db/INNTEKT_BRUTTOFORM 2014-12-31 as wealth_household_member14 collapse(sum) wealth_household_member14, by(household_id14) rename wealth_household_member14 household_wealth14 merge household_wealth14 into household_DS_all on PERSONID_1 delete-dataset household_DS_wealth14 clone-dataset person_DS_Y15 household_DS_wealth15 use household_DS_wealth15 import db/INNTEKT_BRUTTOFORM 2015-12-31 as wealth_household_member15 collapse(sum) wealth_household_member15, by(household_id15) rename wealth_household_member15 household_wealth15 merge household_wealth15 into household_DS_all on PERSONID_1 delete-dataset household_DS_wealth15 clone-dataset person_DS_Y16 household_DS_wealth16 use household_DS_wealth16 import db/INNTEKT_BRUTTOFORM 2016-12-31 as wealth_household_member16 collapse(sum) wealth_household_member16, by(household_id16) rename wealth_household_member16 household_wealth16 merge household_wealth16 into household_DS_all on PERSONID_1 delete-dataset household_DS_wealth16 clone-dataset person_DS_Y17 household_DS_wealth17 use household_DS_wealth17 import db/INNTEKT_BRUTTOFORM 2017-12-31 as wealth_household_member17 collapse(sum) wealth_household_member17, by(household_id17) rename wealth_household_member17 household_wealth17 merge household_wealth17 into household_DS_all on PERSONID_1 delete-dataset household_DS_wealth17 clone-dataset person_DS_Y18 household_DS_wealth18 use household_DS_wealth18 import db/INNTEKT_BRUTTOFORM 2018-12-31 as wealth_household_member18 collapse(sum) wealth_household_member18, by(household_id18) rename wealth_household_member18 household_wealth18 merge household_wealth18 into household_DS_all on PERSONID_1 delete-dataset household_DS_wealth18 clone-dataset person_DS_Y19 household_DS_wealth19 use household_DS_wealth19 import db/INNTEKT_BRUTTOFORM 2019-12-31 as wealth_household_member19 collapse(sum) wealth_household_member19, by(household_id19) rename wealth_household_member19 household_wealth19 merge household_wealth19 into household_DS_all on PERSONID_1 delete-dataset household_DS_wealth19 clone-dataset person_DS_Y20 household_DS_wealth20 use household_DS_wealth20 import db/INNTEKT_BRUTTOFORM 2020-12-31 as wealth_household_member20 collapse(sum) wealth_household_member20, by(household_id20) rename wealth_household_member20 household_wealth20 merge household_wealth20 into household_DS_all on PERSONID_1 delete-dataset household_DS_wealth20 // Wealth data for 2021 is not available in database v.26 textblock clone-dataset person_DS_Y21 household_DS_wealth21 use household_DS_wealth21 import db/INNTEKT_BRUTTOFORM 2021-12-31 as wealth_household_member21 collapse(sum) wealth_household_member21, by(household_id21) rename wealth_household_member21 household_wealth21 merge household_wealth21 into household_DS_all on PERSONID_1 delete-dataset household_DS_wealth21 endblock // Calculating household level debt (unit type = household) in temporary datasets: From 2005 to 2021 clone-dataset person_DS_Y05 household_DS_debt05 use household_DS_debt05 import db/SKATT_GJELD 2005-12-31 as debt_household_member05 // Debt to Norwegian and foreign creditors as well as unit owners' share of the housing association's debt. In the tax statistics for individuals, debt from 2017 includes debt reduction due to valuation discounts. https://www.ssb.no/a/metadata/conceptvariable/vardok/17/nb. The variable covers all taxable persons during the income year. Including persons with dnr. Observations with the values ​​0 and unspecified (missing) are omitted. collapse(sum) debt_household_member05, by(household_id05) rename debt_household_member05 household_debt05 histogram household_debt05, width(100000) freq // This command generates a histogram of income with a width of NOK 100'000. merge household_debt05 into household_DS_all on PERSONID_1 delete-dataset household_DS_debt05 clone-dataset person_DS_Y06 household_DS_debt06 use household_DS_debt06 import db/SKATT_GJELD 2006-12-31 as debt_household_member06 collapse(sum) debt_household_member06, by(household_id06) rename debt_household_member06 household_debt06 merge household_debt06 into household_DS_all on PERSONID_1 delete-dataset household_DS_debt06 clone-dataset person_DS_Y07 household_DS_debt07 use household_DS_debt07 import db/SKATT_GJELD 2007-12-31 as debt_household_member07 collapse(sum) debt_household_member07, by(household_id07) rename debt_household_member07 household_debt07 merge household_debt07 into household_DS_all on PERSONID_1 delete-dataset household_DS_debt07 clone-dataset person_DS_Y08 household_DS_debt08 use household_DS_debt08 import db/SKATT_GJELD 2008-12-31 as debt_household_member08 collapse(sum) debt_household_member08, by(household_id08) rename debt_household_member08 household_debt08 merge household_debt08 into household_DS_all on PERSONID_1 delete-dataset household_DS_debt08 clone-dataset person_DS_Y09 household_DS_debt09 use household_DS_debt09 import db/SKATT_GJELD 2009-12-31 as debt_household_member09 collapse(sum) debt_household_member09, by(household_id09) rename debt_household_member09 household_debt09 merge household_debt09 into household_DS_all on PERSONID_1 delete-dataset household_DS_debt09 clone-dataset person_DS_Y10 household_DS_debt10 use household_DS_debt10 import db/SKATT_GJELD 2010-12-31 as debt_household_member10 collapse(sum) debt_household_member10, by(household_id10) rename debt_household_member10 household_debt10 merge household_debt10 into household_DS_all on PERSONID_1 delete-dataset household_DS_debt10 clone-dataset person_DS_Y11 household_DS_debt11 use household_DS_debt11 import db/SKATT_GJELD 2011-12-31 as debt_household_member11 collapse(sum) debt_household_member11, by(household_id11) rename debt_household_member11 household_debt11 merge household_debt11 into household_DS_all on PERSONID_1 delete-dataset household_DS_debt11 clone-dataset person_DS_Y12 household_DS_debt12 use household_DS_debt12 import db/SKATT_GJELD 2012-12-31 as debt_household_member12 collapse(sum) debt_household_member12, by(household_id12) rename debt_household_member12 household_debt12 merge household_debt12 into household_DS_all on PERSONID_1 delete-dataset household_DS_debt12 clone-dataset person_DS_Y13 household_DS_debt13 use household_DS_debt13 import db/SKATT_GJELD 2013-12-31 as debt_household_member13 collapse(sum) debt_household_member13, by(household_id13) rename debt_household_member13 household_debt13 merge household_debt13 into household_DS_all on PERSONID_1 delete-dataset household_DS_debt13 clone-dataset person_DS_Y14 household_DS_debt14 use household_DS_debt14 import db/SKATT_GJELD 2014-12-31 as debt_household_member14 collapse(sum) debt_household_member14, by(household_id14) rename debt_household_member14 household_debt14 merge household_debt14 into household_DS_all on PERSONID_1 delete-dataset household_DS_debt14 clone-dataset person_DS_Y15 household_DS_debt15 use household_DS_debt15 import db/SKATT_GJELD 2015-12-31 as debt_household_member15 collapse(sum) debt_household_member15, by(household_id15) rename debt_household_member15 household_debt15 merge household_debt15 into household_DS_all on PERSONID_1 delete-dataset household_DS_debt15 clone-dataset person_DS_Y16 household_DS_debt16 use household_DS_debt16 import db/SKATT_GJELD 2016-12-31 as debt_household_member16 collapse(sum) debt_household_member16, by(household_id16) rename debt_household_member16 household_debt16 merge household_debt16 into household_DS_all on PERSONID_1 delete-dataset household_DS_debt16 clone-dataset person_DS_Y17 household_DS_debt17 use household_DS_debt17 import db/SKATT_GJELD 2017-12-31 as debt_household_member17 collapse(sum) debt_household_member17, by(household_id17) rename debt_household_member17 household_debt17 merge household_debt17 into household_DS_all on PERSONID_1 delete-dataset household_DS_debt17 clone-dataset person_DS_Y18 household_DS_debt18 use household_DS_debt18 import db/SKATT_GJELD 2018-12-31 as debt_household_member18 collapse(sum) debt_household_member18, by(household_id18) rename debt_household_member18 household_debt18 merge household_debt18 into household_DS_all on PERSONID_1 delete-dataset household_DS_debt18 clone-dataset person_DS_Y19 household_DS_debt19 use household_DS_debt19 import db/SKATT_GJELD 2019-12-31 as debt_household_member19 collapse(sum) debt_household_member19, by(household_id19) rename debt_household_member19 household_debt19 merge household_debt19 into household_DS_all on PERSONID_1 delete-dataset household_DS_debt19 clone-dataset person_DS_Y20 household_DS_debt20 use household_DS_debt20 import db/SKATT_GJELD 2020-12-31 as debt_household_member20 collapse(sum) debt_household_member20, by(household_id20) rename debt_household_member20 household_debt20 merge household_debt20 into household_DS_all on PERSONID_1 delete-dataset household_DS_debt20 clone-dataset person_DS_Y21 household_DS_debt21 use household_DS_debt21 import db/SKATT_GJELD 2021-12-31 as debt_household_member21 collapse(sum) debt_household_member21, by(household_id21) rename debt_household_member21 household_debt21 merge household_debt21 into household_DS_all on PERSONID_1 delete-dataset household_DS_debt21 textblock Household Dataset: highest completed education in the household ------------------ ::::: The highest completed education for each person is called and then aggregated onto the household level at this step. By doing so, the highest completed education in the household is identified. Note: NUS2000 (NUS code) is the code for the highest completed education according to the definition of education level drawn up in 2006. For more information, see https://www.ssb.no/utdanning/artikler-og-publikasjoner/hvordan-klassifiseres-en-persons-hoyeste-utdanningsniva Note: the data related to education (according to NUS2000) has 5,322 categories. endblock // Importing the highest completed education for each person: needed for aggregation and finding the highest level of education in the household clone-dataset person_DS_Y05 household_DS_edu05 use household_DS_edu05 import db/NUDB_BU 2005-12-31 as education_level_person05 //tabulate education_level_person, missing // Squeezing the total categories of "education_level_person" generate education_level_person_aggregated05 = substr(education_level_person05, 1, 1) // Note: Level 0 is actually "kindergarten/preschool education or no education". // See more at https://www.ssb.no/en/utdanning/artikler-og-publikasjoner/facts-about-education-in-norway-2021 define-labels education_level_aggregated_txt '0' 'No school edu.' '1' 'Primary edu.' '2' 'Lower secondary edu.' '3' 'Upper secondary edu.' '4' 'Post secondary (Prof. degree)' '5' 'Post secondary (Higher prof. degree)' '6' 'Bachelor degree' '7' 'Master degree' '8' 'PhD degree' assign-labels education_level_person_aggregated05 education_level_aggregated_txt tabulate education_level_person_aggregated05, missing piechart education_level_person_aggregated05 // Following, the "_numeric" will be used for correlation & regression. // Find the highest level of education in the household in 2005. collapse(max) education_level_person_aggregated05, by(household_id05) rename education_level_person_aggregated05 household_highest_edu05 //assign-labels household_highest_edu05 education_level_aggregated_txt //tabulate household_highest_edu05, missing generate household_highest_edu_numeric05 = household_highest_edu05 destring household_highest_edu_numeric05 //merge household_highest_edu05 into household_DS_all on PERSONID_1 merge household_highest_edu_numeric05 into household_DS_all on PERSONID_1 delete-dataset household_DS_edu05 // 2006 edu clone-dataset person_DS_Y06 household_DS_edu06 use household_DS_edu06 import db/NUDB_BU 2006-12-31 as education_level_person06 generate education_level_person_aggregated06 = substr(education_level_person06, 1, 1) assign-labels education_level_person_aggregated06 education_level_aggregated_txt tabulate education_level_person_aggregated06, missing // Find the highest level of education in the household in 2006. collapse(max) education_level_person_aggregated06, by(household_id06) rename education_level_person_aggregated06 household_highest_edu06 //assign-labels household_highest_edu06 education_level_aggregated_txt //tabulate household_highest_edu06, missing generate household_highest_edu_numeric06 = household_highest_edu06 destring household_highest_edu_numeric06 //merge household_highest_edu06 into household_DS_all on PERSONID_1 merge household_highest_edu_numeric06 into household_DS_all on PERSONID_1 delete-dataset household_DS_edu06 // 2007 edu clone-dataset person_DS_Y07 household_DS_edu07 use household_DS_edu07 import db/NUDB_BU 2007-12-31 as education_level_person07 generate education_level_person_aggregated07 = substr(education_level_person07, 1, 1) assign-labels education_level_person_aggregated07 education_level_aggregated_txt tabulate education_level_person_aggregated07, missing // Find the highest level of education in the household in 2007. collapse(max) education_level_person_aggregated07, by(household_id07) rename education_level_person_aggregated07 household_highest_edu07 //assign-labels household_highest_edu07 education_level_aggregated_txt //tabulate household_highest_edu07, missing generate household_highest_edu_numeric07 = household_highest_edu07 destring household_highest_edu_numeric07 //merge household_highest_edu07 into household_DS_all on PERSONID_1 merge household_highest_edu_numeric07 into household_DS_all on PERSONID_1 delete-dataset household_DS_edu07 // 2008 edu clone-dataset person_DS_Y08 household_DS_edu08 use household_DS_edu08 import db/NUDB_BU 2008-12-31 as education_level_person08 generate education_level_person_aggregated08 = substr(education_level_person08, 1, 1) assign-labels education_level_person_aggregated08 education_level_aggregated_txt tabulate education_level_person_aggregated08, missing // Find the highest level of education in the household in 2008. collapse(max) education_level_person_aggregated08, by(household_id08) rename education_level_person_aggregated08 household_highest_edu08 //assign-labels household_highest_edu08 education_level_aggregated_txt //tabulate household_highest_edu08, missing generate household_highest_edu_numeric08 = household_highest_edu08 destring household_highest_edu_numeric08 //merge household_highest_edu08 into household_DS_all on PERSONID_1 merge household_highest_edu_numeric08 into household_DS_all on PERSONID_1 delete-dataset household_DS_edu08 // 2009 edu clone-dataset person_DS_Y09 household_DS_edu09 use household_DS_edu09 import db/NUDB_BU 2009-12-31 as education_level_person09 generate education_level_person_aggregated09 = substr(education_level_person09, 1, 1) assign-labels education_level_person_aggregated09 education_level_aggregated_txt tabulate education_level_person_aggregated09, missing // Find the highest level of education in the household in 2009. collapse(max) education_level_person_aggregated09, by(household_id09) rename education_level_person_aggregated09 household_highest_edu09 //assign-labels household_highest_edu09 education_level_aggregated_txt //tabulate household_highest_edu09, missing generate household_highest_edu_numeric09 = household_highest_edu09 destring household_highest_edu_numeric09 //merge household_highest_edu09 into household_DS_all on PERSONID_1 merge household_highest_edu_numeric09 into household_DS_all on PERSONID_1 delete-dataset household_DS_edu09 // 2010 edu clone-dataset person_DS_Y10 household_DS_edu10 use household_DS_edu10 import db/NUDB_BU 2010-12-31 as education_level_person10 generate education_level_person_aggregated10 = substr(education_level_person10, 1, 1) assign-labels education_level_person_aggregated10 education_level_aggregated_txt tabulate education_level_person_aggregated10, missing // Find the highest level of education in the household in 2010. collapse(max) education_level_person_aggregated10, by(household_id10) rename education_level_person_aggregated10 household_highest_edu10 //assign-labels household_highest_edu10 education_level_aggregated_txt //tabulate household_highest_edu10, missing generate household_highest_edu_numeric10 = household_highest_edu10 destring household_highest_edu_numeric10 //merge household_highest_edu10 into household_DS_all on PERSONID_1 merge household_highest_edu_numeric10 into household_DS_all on PERSONID_1 delete-dataset household_DS_edu10 // 2011 edu clone-dataset person_DS_Y11 household_DS_edu11 use household_DS_edu11 import db/NUDB_BU 2011-12-31 as education_level_person11 generate education_level_person_aggregated11 = substr(education_level_person11, 1, 1) assign-labels education_level_person_aggregated11 education_level_aggregated_txt tabulate education_level_person_aggregated11, missing // Find the highest level of education in the household in 2011. collapse(max) education_level_person_aggregated11, by(household_id11) rename education_level_person_aggregated11 household_highest_edu11 //assign-labels household_highest_edu11 education_level_aggregated_txt //tabulate household_highest_edu11, missing generate household_highest_edu_numeric11 = household_highest_edu11 destring household_highest_edu_numeric11 //merge household_highest_edu11 into household_DS_all on PERSONID_1 merge household_highest_edu_numeric11 into household_DS_all on PERSONID_1 delete-dataset household_DS_edu11 // 2012 edu clone-dataset person_DS_Y12 household_DS_edu12 use household_DS_edu12 import db/NUDB_BU 2012-12-31 as education_level_person12 generate education_level_person_aggregated12 = substr(education_level_person12, 1, 1) assign-labels education_level_person_aggregated12 education_level_aggregated_txt tabulate education_level_person_aggregated12, missing // Find the highest level of education in the household in 2012. collapse(max) education_level_person_aggregated12, by(household_id12) rename education_level_person_aggregated12 household_highest_edu12 //assign-labels household_highest_edu12 education_level_aggregated_txt //tabulate household_highest_edu12, missing generate household_highest_edu_numeric12 = household_highest_edu12 destring household_highest_edu_numeric12 //merge household_highest_edu12 into household_DS_all on PERSONID_1 merge household_highest_edu_numeric12 into household_DS_all on PERSONID_1 delete-dataset household_DS_edu12 // 2013 edu clone-dataset person_DS_Y13 household_DS_edu13 use household_DS_edu13 import db/NUDB_BU 2013-12-31 as education_level_person13 generate education_level_person_aggregated13 = substr(education_level_person13, 1, 1) assign-labels education_level_person_aggregated13 education_level_aggregated_txt tabulate education_level_person_aggregated13, missing // Find the highest level of education in the household in 2013. collapse(max) education_level_person_aggregated13, by(household_id13) rename education_level_person_aggregated13 household_highest_edu13 //assign-labels household_highest_edu13 education_level_aggregated_txt //tabulate household_highest_edu13, missing generate household_highest_edu_numeric13 = household_highest_edu13 destring household_highest_edu_numeric13 //merge household_highest_edu13 into household_DS_all on PERSONID_1 merge household_highest_edu_numeric13 into household_DS_all on PERSONID_1 delete-dataset household_DS_edu13 // 2014 edu clone-dataset person_DS_Y14 household_DS_edu14 use household_DS_edu14 import db/NUDB_BU 2014-12-31 as education_level_person14 generate education_level_person_aggregated14 = substr(education_level_person14, 1, 1) assign-labels education_level_person_aggregated14 education_level_aggregated_txt tabulate education_level_person_aggregated14, missing // Find the highest level of education in the household in 2014. collapse(max) education_level_person_aggregated14, by(household_id14) rename education_level_person_aggregated14 household_highest_edu14 //assign-labels household_highest_edu14 education_level_aggregated_txt //tabulate household_highest_edu14, missing generate household_highest_edu_numeric14 = household_highest_edu14 destring household_highest_edu_numeric14 //merge household_highest_edu14 into household_DS_all on PERSONID_1 merge household_highest_edu_numeric14 into household_DS_all on PERSONID_1 delete-dataset household_DS_edu14 // 2015 edu clone-dataset person_DS_Y15 household_DS_edu15 use household_DS_edu15 import db/NUDB_BU 2015-12-31 as education_level_person15 generate education_level_person_aggregated15 = substr(education_level_person15, 1, 1) assign-labels education_level_person_aggregated15 education_level_aggregated_txt tabulate education_level_person_aggregated15, missing // Find the highest level of education in the household in 2015. collapse(max) education_level_person_aggregated15, by(household_id15) rename education_level_person_aggregated15 household_highest_edu15 //assign-labels household_highest_edu15 education_level_aggregated_txt //tabulate household_highest_edu15, missing generate household_highest_edu_numeric15 = household_highest_edu15 destring household_highest_edu_numeric15 //merge household_highest_edu15 into household_DS_all on PERSONID_1 merge household_highest_edu_numeric15 into household_DS_all on PERSONID_1 delete-dataset household_DS_edu15 // 2016 edu clone-dataset person_DS_Y16 household_DS_edu16 use household_DS_edu16 import db/NUDB_BU 2016-12-31 as education_level_person16 generate education_level_person_aggregated16 = substr(education_level_person16, 1, 1) assign-labels education_level_person_aggregated16 education_level_aggregated_txt tabulate education_level_person_aggregated16, missing // Find the highest level of education in the household in 2016. collapse(max) education_level_person_aggregated16, by(household_id16) rename education_level_person_aggregated16 household_highest_edu16 //assign-labels household_highest_edu16 education_level_aggregated_txt //tabulate household_highest_edu16, missing generate household_highest_edu_numeric16 = household_highest_edu16 destring household_highest_edu_numeric16 //merge household_highest_edu16 into household_DS_all on PERSONID_1 merge household_highest_edu_numeric16 into household_DS_all on PERSONID_1 delete-dataset household_DS_edu16 // 2017 edu clone-dataset person_DS_Y17 household_DS_edu17 use household_DS_edu17 import db/NUDB_BU 2017-12-31 as education_level_person17 generate education_level_person_aggregated17 = substr(education_level_person17, 1, 1) assign-labels education_level_person_aggregated17 education_level_aggregated_txt tabulate education_level_person_aggregated17, missing // Find the highest level of education in the household in 2017. collapse(max) education_level_person_aggregated17, by(household_id17) rename education_level_person_aggregated17 household_highest_edu17 //assign-labels household_highest_edu17 education_level_aggregated_txt //tabulate household_highest_edu17, missing generate household_highest_edu_numeric17 = household_highest_edu17 destring household_highest_edu_numeric17 //merge household_highest_edu17 into household_DS_all on PERSONID_1 merge household_highest_edu_numeric17 into household_DS_all on PERSONID_1 delete-dataset household_DS_edu17 // 2018 edu clone-dataset person_DS_Y18 household_DS_edu18 use household_DS_edu18 import db/NUDB_BU 2018-12-31 as education_level_person18 generate education_level_person_aggregated18 = substr(education_level_person18, 1, 1) assign-labels education_level_person_aggregated18 education_level_aggregated_txt tabulate education_level_person_aggregated18, missing // Find the highest level of education in the household in 2018. collapse(max) education_level_person_aggregated18, by(household_id18) rename education_level_person_aggregated18 household_highest_edu18 //assign-labels household_highest_edu18 education_level_aggregated_txt //tabulate household_highest_edu18, missing generate household_highest_edu_numeric18 = household_highest_edu18 destring household_highest_edu_numeric18 //merge household_highest_edu18 into household_DS_all on PERSONID_1 merge household_highest_edu_numeric18 into household_DS_all on PERSONID_1 delete-dataset household_DS_edu18 // 2019 edu clone-dataset person_DS_Y19 household_DS_edu19 use household_DS_edu19 import db/NUDB_BU 2019-12-31 as education_level_person19 generate education_level_person_aggregated19 = substr(education_level_person19, 1, 1) assign-labels education_level_person_aggregated19 education_level_aggregated_txt tabulate education_level_person_aggregated19, missing // Find the highest level of education in the household in 2019. collapse(max) education_level_person_aggregated19, by(household_id19) rename education_level_person_aggregated19 household_highest_edu19 //assign-labels household_highest_edu19 education_level_aggregated_txt //tabulate household_highest_edu19, missing generate household_highest_edu_numeric19 = household_highest_edu19 destring household_highest_edu_numeric19 //merge household_highest_edu19 into household_DS_all on PERSONID_1 merge household_highest_edu_numeric19 into household_DS_all on PERSONID_1 delete-dataset household_DS_edu19 // 2020 edu clone-dataset person_DS_Y20 household_DS_edu20 use household_DS_edu20 import db/NUDB_BU 2020-12-31 as education_level_person20 generate education_level_person_aggregated20 = substr(education_level_person20, 1, 1) assign-labels education_level_person_aggregated20 education_level_aggregated_txt tabulate education_level_person_aggregated20, missing // Find the highest level of education in the household in 2020. collapse(max) education_level_person_aggregated20, by(household_id20) rename education_level_person_aggregated20 household_highest_edu20 //assign-labels household_highest_edu20 education_level_aggregated_txt //tabulate household_highest_edu20, missing generate household_highest_edu_numeric20 = household_highest_edu20 destring household_highest_edu_numeric20 //merge household_highest_edu20 into household_DS_all on PERSONID_1 merge household_highest_edu_numeric20 into household_DS_all on PERSONID_1 delete-dataset household_DS_edu20 // 2021 edu clone-dataset person_DS_Y21 household_DS_edu21 use household_DS_edu21 import db/NUDB_BU 2021-12-31 as education_level_person21 //tabulate education_level_person, missing generate education_level_person_aggregated21 = substr(education_level_person21, 1, 1) assign-labels education_level_person_aggregated21 education_level_aggregated_txt tabulate education_level_person_aggregated21, missing // Find the highest level of education in the household in 2021. collapse(max) education_level_person_aggregated21, by(household_id21) rename education_level_person_aggregated21 household_highest_edu21 //assign-labels household_highest_edu21 education_level_aggregated_txt //tabulate household_highest_edu21, missing generate household_highest_edu_numeric21 = household_highest_edu21 destring household_highest_edu_numeric21 //merge household_highest_edu21 into household_DS_all on PERSONID_1 merge household_highest_edu_numeric21 into household_DS_all on PERSONID_1 delete-dataset household_DS_edu21 // 2022 edu // #Note that the latest data is until 2022-09-01 clone-dataset person_DS_Y22 household_DS_edu22 use household_DS_edu22 import db/NUDB_BU 2022-09-01 as education_level_person22 //tabulate education_level_person, missing generate education_level_person_aggregated22 = substr(education_level_person22, 1, 1) assign-labels education_level_person_aggregated22 education_level_aggregated_txt tabulate education_level_person_aggregated22, missing // Find the highest level of education in the household in 2022. collapse(max) education_level_person_aggregated22, by(household_id22) rename education_level_person_aggregated22 household_highest_edu22 //assign-labels household_highest_edu22 education_level_aggregated_txt //tabulate household_highest_edu22, missing generate household_highest_edu_numeric22 = household_highest_edu22 destring household_highest_edu_numeric22 //merge household_highest_edu22 into household_DS_all on PERSONID_1 merge household_highest_edu_numeric22 into household_DS_all on PERSONID_1 delete-dataset household_DS_edu22 textblock Adding further demographical information ... ------------------- ::::: Types of household endblock clone-dataset person_DS_Y05 household_DS_type05 use household_DS_type05 // Importing detailed breakdown of household types: 24 categories import db/BEFOLKNING_REGSTAT_HUSHTYP 2005-01-01 as household_type05, outer_join // Define and assign the English translation to each category. define-labels household_type_txt '1.1.1' 'Living alone under 30 years' '1.1.2' 'Living alone 30-44 years' '1.1.3' 'Living alone 45-66 years' '1.1.4' 'Living alone 67 years and over' '1.2.1' 'Couple without children, oldest person under 30 years' '1.2.2' 'Couple without children, oldest person 30-44 years' '1.2.3' 'Couple without children, oldest person 45-66 years' '1.2.4' 'Couple without children, oldest person 67 years and over' '1.3.1' 'Married couple with small children (youngest children 0-5 years)' '1.3.2' 'Cohabiting couple with small children (youngest child 0-5 years)' '1.4.1' 'Married couple with older children (youngest children 6-17 years)' '1.4.2' 'Cohabiting couple with older children (youngest child 6-17 years)' '1.5.1' 'Mother with small children (youngest child 0-5 years)' '1.5.2' 'Father with small children (youngest child 0-5 years)' '1.6.1' 'Mother with older children (youngest child 6-17 years)' '1.6.2' 'Father with older children (youngest child 6-17 years)' '1.7.1' 'Married couple with adult children (youngest child 18 years and over)' '1.7.2' 'Cohabiting couple with adult children (youngest child 18 years and over)' '1.7.3' 'Mother with adult children (youngest child 18 years and over)' '1.7.4' 'Father with adult children (youngest child 18 years and over)' '2.1.1' 'Households with two or more single-person families' '2.1.2' 'Other multi-family households without children 0-17 years' '2.2.0' 'Multi-family households with small children (youngest children under 0-5 years)' '2.3.0' 'Multi-family households with older children (youngest children 6-17 years)' assign-labels household_type05 household_type_txt //tabulate household_type, missing generate resident05 = 1 barchart(count) resident05, over(household_type05) // Squeezing the total number of "household_type": according to the age category of children in the household // Note: According to SSB, the age of the youngest child determines the type of household. generate household_type_by_children05 = household_type05 replace household_type_by_children05 = '0 Without children' if household_type_by_children05 == '1.1.1' | household_type_by_children05 == '1.1.2' | household_type_by_children05 == '1.1.3' | household_type_by_children05 == '1.1.4' | household_type_by_children05 == '1.2.1' | household_type_by_children05 == '1.2.2' | household_type_by_children05 == '1.2.3' | household_type_by_children05 == '1.2.4' | household_type_by_children05 == '2.1.1' | household_type_by_children05 == '2.1.2' replace household_type_by_children05 = '1 With small children' if household_type_by_children05 == '1.3.1' | household_type_by_children05 == '1.3.2' | household_type_by_children05 == '1.5.1' | household_type_by_children05 == '1.5.2' | household_type_by_children05 == '2.2.0' replace household_type_by_children05 = '2 With older children' if household_type_by_children05 == '1.4.1' | household_type_by_children05 == '1.4.2' | household_type_by_children05 == '1.6.1' | household_type_by_children05 == '1.6.2' | household_type_by_children05 == '2.3.0' replace household_type_by_children05 = '3 With adult children' if household_type_by_children05 == '1.7.1' | household_type_by_children05 == '1.7.2' | household_type_by_children05 == '1.7.3' | household_type_by_children05 == '1.7.4' tabulate household_type_by_children05, missing merge household_type_by_children05 into household_DS_all on PERSONID_1 generate type_have_children05 = 0 replace type_have_children05 = 1 if household_type05 == '1.3.1' | household_type05 == '1.3.2' | household_type05 == '1.5.1' | household_type05 == '1.5.2' | household_type05 == '2.2.0' | household_type05 == '1.4.1' | household_type05 == '1.4.2' | household_type05 == '1.6.1' | household_type05 == '1.6.2' | household_type05 == '2.3.0' | household_type05 == '1.7.1' | household_type05 == '1.7.2' | household_type05 == '1.7.3' | household_type05 == '1.7.4' tabulate type_have_children05, missing merge type_have_children05 into household_DS_all on PERSONID_1 delete-dataset household_DS_type05 // and, the following years ... // Household type by children 2006 clone-dataset person_DS_Y06 household_DS_type06 use household_DS_type06 import db/BEFOLKNING_REGSTAT_HUSHTYP 2006-01-01 as household_type06 assign-labels household_type06 household_type_txt generate household_type_by_children06 = household_type06 replace household_type_by_children06 = '0 Without children' if household_type_by_children06 == '1.1.1' | household_type_by_children06 == '1.1.2' | household_type_by_children06 == '1.1.3' | household_type_by_children06 == '1.1.4' | household_type_by_children06 == '1.2.1' | household_type_by_children06 == '1.2.2' | household_type_by_children06 == '1.2.3' | household_type_by_children06 == '1.2.4' | household_type_by_children06 == '2.1.1' | household_type_by_children06 == '2.1.2' replace household_type_by_children06 = '1 With small children' if household_type_by_children06 == '1.3.1' | household_type_by_children06 == '1.3.2' | household_type_by_children06 == '1.5.1' | household_type_by_children06 == '1.5.2' | household_type_by_children06 == '2.2.0' replace household_type_by_children06 = '2 With older children' if household_type_by_children06 == '1.4.1' | household_type_by_children06 == '1.4.2' | household_type_by_children06 == '1.6.1' | household_type_by_children06 == '1.6.2' | household_type_by_children06 == '2.3.0' replace household_type_by_children06 = '3 With adult children' if household_type_by_children06 == '1.7.1' | household_type_by_children06 == '1.7.2' | household_type_by_children06 == '1.7.3' | household_type_by_children06 == '1.7.4' tabulate household_type_by_children06, missing merge household_type_by_children06 into household_DS_all on PERSONID_1 generate type_have_children06 = 0 replace type_have_children06 = 1 if household_type06 == '1.3.1' | household_type06 == '1.3.2' | household_type06 == '1.5.1' | household_type06 == '1.5.2' | household_type06 == '2.2.0' | household_type06 == '1.4.1' | household_type06 == '1.4.2' | household_type06 == '1.6.1' | household_type06 == '1.6.2' | household_type06 == '2.3.0' | household_type06 == '1.7.1' | household_type06 == '1.7.2' | household_type06 == '1.7.3' | household_type06 == '1.7.4' tabulate type_have_children06, missing merge type_have_children06 into household_DS_all on PERSONID_1 delete-dataset household_DS_type06 // Household type by children 2007 clone-dataset person_DS_Y07 household_DS_type07 use household_DS_type07 import db/BEFOLKNING_REGSTAT_HUSHTYP 2007-01-01 as household_type07 assign-labels household_type07 household_type_txt generate household_type_by_children07 = household_type07 replace household_type_by_children07 = '0 Without children' if household_type_by_children07 == '1.1.1' | household_type_by_children07 == '1.1.2' | household_type_by_children07 == '1.1.3' | household_type_by_children07 == '1.1.4' | household_type_by_children07 == '1.2.1' | household_type_by_children07 == '1.2.2' | household_type_by_children07 == '1.2.3' | household_type_by_children07 == '1.2.4' | household_type_by_children07 == '2.1.1' | household_type_by_children07 == '2.1.2' replace household_type_by_children07 = '1 With small children' if household_type_by_children07 == '1.3.1' | household_type_by_children07 == '1.3.2' | household_type_by_children07 == '1.5.1' | household_type_by_children07 == '1.5.2' | household_type_by_children07 == '2.2.0' replace household_type_by_children07 = '2 With older children' if household_type_by_children07 == '1.4.1' | household_type_by_children07 == '1.4.2' | household_type_by_children07 == '1.6.1' | household_type_by_children07 == '1.6.2' | household_type_by_children07 == '2.3.0' replace household_type_by_children07 = '3 With adult children' if household_type_by_children07 == '1.7.1' | household_type_by_children07 == '1.7.2' | household_type_by_children07 == '1.7.3' | household_type_by_children07 == '1.7.4' tabulate household_type_by_children07, missing merge household_type_by_children07 into household_DS_all on PERSONID_1 generate type_have_children07 = 0 replace type_have_children07 = 1 if household_type07 == '1.3.1' | household_type07 == '1.3.2' | household_type07 == '1.5.1' | household_type07 == '1.5.2' | household_type07 == '2.2.0' | household_type07 == '1.4.1' | household_type07 == '1.4.2' | household_type07 == '1.6.1' | household_type07 == '1.6.2' | household_type07 == '2.3.0' | household_type07 == '1.7.1' | household_type07 == '1.7.2' | household_type07 == '1.7.3' | household_type07 == '1.7.4' tabulate type_have_children07, missing merge type_have_children07 into household_DS_all on PERSONID_1 delete-dataset household_DS_type07 // Household type by children 2008 clone-dataset person_DS_Y08 household_DS_type08 use household_DS_type08 import db/BEFOLKNING_REGSTAT_HUSHTYP 2008-01-01 as household_type08 assign-labels household_type08 household_type_txt generate household_type_by_children08 = household_type08 replace household_type_by_children08 = '0 Without children' if household_type_by_children08 == '1.1.1' | household_type_by_children08 == '1.1.2' | household_type_by_children08 == '1.1.3' | household_type_by_children08 == '1.1.4' | household_type_by_children08 == '1.2.1' | household_type_by_children08 == '1.2.2' | household_type_by_children08 == '1.2.3' | household_type_by_children08 == '1.2.4' | household_type_by_children08 == '2.1.1' | household_type_by_children08 == '2.1.2' replace household_type_by_children08 = '1 With small children' if household_type_by_children08 == '1.3.1' | household_type_by_children08 == '1.3.2' | household_type_by_children08 == '1.5.1' | household_type_by_children08 == '1.5.2' | household_type_by_children08 == '2.2.0' replace household_type_by_children08 = '2 With older children' if household_type_by_children08 == '1.4.1' | household_type_by_children08 == '1.4.2' | household_type_by_children08 == '1.6.1' | household_type_by_children08 == '1.6.2' | household_type_by_children08 == '2.3.0' replace household_type_by_children08 = '3 With adult children' if household_type_by_children08 == '1.7.1' | household_type_by_children08 == '1.7.2' | household_type_by_children08 == '1.7.3' | household_type_by_children08 == '1.7.4' tabulate household_type_by_children08, missing merge household_type_by_children08 into household_DS_all on PERSONID_1 generate type_have_children08 = 0 replace type_have_children08 = 1 if household_type08 == '1.3.1' | household_type08 == '1.3.2' | household_type08 == '1.5.1' | household_type08 == '1.5.2' | household_type08 == '2.2.0' | household_type08 == '1.4.1' | household_type08 == '1.4.2' | household_type08 == '1.6.1' | household_type08 == '1.6.2' | household_type08 == '2.3.0' | household_type08 == '1.7.1' | household_type08 == '1.7.2' | household_type08 == '1.7.3' | household_type08 == '1.7.4' tabulate type_have_children08, missing merge type_have_children08 into household_DS_all on PERSONID_1 delete-dataset household_DS_type08 // Household type by children 2009 clone-dataset person_DS_Y09 household_DS_type09 use household_DS_type09 import db/BEFOLKNING_REGSTAT_HUSHTYP 2009-01-01 as household_type09 assign-labels household_type09 household_type_txt generate household_type_by_children09 = household_type09 replace household_type_by_children09 = '0 Without children' if household_type_by_children09 == '1.1.1' | household_type_by_children09 == '1.1.2' | household_type_by_children09 == '1.1.3' | household_type_by_children09 == '1.1.4' | household_type_by_children09 == '1.2.1' | household_type_by_children09 == '1.2.2' | household_type_by_children09 == '1.2.3' | household_type_by_children09 == '1.2.4' | household_type_by_children09 == '2.1.1' | household_type_by_children09 == '2.1.2' replace household_type_by_children09 = '1 With small children' if household_type_by_children09 == '1.3.1' | household_type_by_children09 == '1.3.2' | household_type_by_children09 == '1.5.1' | household_type_by_children09 == '1.5.2' | household_type_by_children09 == '2.2.0' replace household_type_by_children09 = '2 With older children' if household_type_by_children09 == '1.4.1' | household_type_by_children09 == '1.4.2' | household_type_by_children09 == '1.6.1' | household_type_by_children09 == '1.6.2' | household_type_by_children09 == '2.3.0' replace household_type_by_children09 = '3 With adult children' if household_type_by_children09 == '1.7.1' | household_type_by_children09 == '1.7.2' | household_type_by_children09 == '1.7.3' | household_type_by_children09 == '1.7.4' tabulate household_type_by_children09, missing merge household_type_by_children09 into household_DS_all on PERSONID_1 generate type_have_children09 = 0 replace type_have_children09 = 1 if household_type09 == '1.3.1' | household_type09 == '1.3.2' | household_type09 == '1.5.1' | household_type09 == '1.5.2' | household_type09 == '2.2.0' | household_type09 == '1.4.1' | household_type09 == '1.4.2' | household_type09 == '1.6.1' | household_type09 == '1.6.2' | household_type09 == '2.3.0' | household_type09 == '1.7.1' | household_type09 == '1.7.2' | household_type09 == '1.7.3' | household_type09 == '1.7.4' tabulate type_have_children09, missing merge type_have_children09 into household_DS_all on PERSONID_1 delete-dataset household_DS_type09 // Household type by children 2010 clone-dataset person_DS_Y10 household_DS_type10 use household_DS_type10 import db/BEFOLKNING_REGSTAT_HUSHTYP 2010-01-01 as household_type10 assign-labels household_type10 household_type_txt generate household_type_by_children10 = household_type10 replace household_type_by_children10 = '0 Without children' if household_type_by_children10 == '1.1.1' | household_type_by_children10 == '1.1.2' | household_type_by_children10 == '1.1.3' | household_type_by_children10 == '1.1.4' | household_type_by_children10 == '1.2.1' | household_type_by_children10 == '1.2.2' | household_type_by_children10 == '1.2.3' | household_type_by_children10 == '1.2.4' | household_type_by_children10 == '2.1.1' | household_type_by_children10 == '2.1.2' replace household_type_by_children10 = '1 With small children' if household_type_by_children10 == '1.3.1' | household_type_by_children10 == '1.3.2' | household_type_by_children10 == '1.5.1' | household_type_by_children10 == '1.5.2' | household_type_by_children10 == '2.2.0' replace household_type_by_children10 = '2 With older children' if household_type_by_children10 == '1.4.1' | household_type_by_children10 == '1.4.2' | household_type_by_children10 == '1.6.1' | household_type_by_children10 == '1.6.2' | household_type_by_children10 == '2.3.0' replace household_type_by_children10 = '3 With adult children' if household_type_by_children10 == '1.7.1' | household_type_by_children10 == '1.7.2' | household_type_by_children10 == '1.7.3' | household_type_by_children10 == '1.7.4' tabulate household_type_by_children10, missing merge household_type_by_children10 into household_DS_all on PERSONID_1 generate type_have_children10 = 0 replace type_have_children10 = 1 if household_type10 == '1.3.1' | household_type10 == '1.3.2' | household_type10 == '1.5.1' | household_type10 == '1.5.2' | household_type10 == '2.2.0' | household_type10 == '1.4.1' | household_type10 == '1.4.2' | household_type10 == '1.6.1' | household_type10 == '1.6.2' | household_type10 == '2.3.0' | household_type10 == '1.7.1' | household_type10 == '1.7.2' | household_type10 == '1.7.3' | household_type10 == '1.7.4' tabulate type_have_children10, missing merge type_have_children10 into household_DS_all on PERSONID_1 delete-dataset household_DS_type10 // Household type by children 2011 clone-dataset person_DS_Y11 household_DS_type11 use household_DS_type11 import db/BEFOLKNING_REGSTAT_HUSHTYP 2011-01-01 as household_type11 assign-labels household_type11 household_type_txt generate household_type_by_children11 = household_type11 replace household_type_by_children11 = '0 Without children' if household_type_by_children11 == '1.1.1' | household_type_by_children11 == '1.1.2' | household_type_by_children11 == '1.1.3' | household_type_by_children11 == '1.1.4' | household_type_by_children11 == '1.2.1' | household_type_by_children11 == '1.2.2' | household_type_by_children11 == '1.2.3' | household_type_by_children11 == '1.2.4' | household_type_by_children11 == '2.1.1' | household_type_by_children11 == '2.1.2' replace household_type_by_children11 = '1 With small children' if household_type_by_children11 == '1.3.1' | household_type_by_children11 == '1.3.2' | household_type_by_children11 == '1.5.1' | household_type_by_children11 == '1.5.2' | household_type_by_children11 == '2.2.0' replace household_type_by_children11 = '2 With older children' if household_type_by_children11 == '1.4.1' | household_type_by_children11 == '1.4.2' | household_type_by_children11 == '1.6.1' | household_type_by_children11 == '1.6.2' | household_type_by_children11 == '2.3.0' replace household_type_by_children11 = '3 With adult children' if household_type_by_children11 == '1.7.1' | household_type_by_children11 == '1.7.2' | household_type_by_children11 == '1.7.3' | household_type_by_children11 == '1.7.4' tabulate household_type_by_children11, missing merge household_type_by_children11 into household_DS_all on PERSONID_1 generate type_have_children11 = 0 replace type_have_children11 = 1 if household_type11 == '1.3.1' | household_type11 == '1.3.2' | household_type11 == '1.5.1' | household_type11 == '1.5.2' | household_type11 == '2.2.0' | household_type11 == '1.4.1' | household_type11 == '1.4.2' | household_type11 == '1.6.1' | household_type11 == '1.6.2' | household_type11 == '2.3.0' | household_type11 == '1.7.1' | household_type11 == '1.7.2' | household_type11 == '1.7.3' | household_type11 == '1.7.4' tabulate type_have_children11, missing merge type_have_children11 into household_DS_all on PERSONID_1 delete-dataset household_DS_type11 // Household type by children 2012 clone-dataset person_DS_Y12 household_DS_type12 use household_DS_type12 import db/BEFOLKNING_REGSTAT_HUSHTYP 2012-01-01 as household_type12 assign-labels household_type12 household_type_txt generate household_type_by_children12 = household_type12 replace household_type_by_children12 = '0 Without children' if household_type_by_children12 == '1.1.1' | household_type_by_children12 == '1.1.2' | household_type_by_children12 == '1.1.3' | household_type_by_children12 == '1.1.4' | household_type_by_children12 == '1.2.1' | household_type_by_children12 == '1.2.2' | household_type_by_children12 == '1.2.3' | household_type_by_children12 == '1.2.4' | household_type_by_children12 == '2.1.1' | household_type_by_children12 == '2.1.2' replace household_type_by_children12 = '1 With small children' if household_type_by_children12 == '1.3.1' | household_type_by_children12 == '1.3.2' | household_type_by_children12 == '1.5.1' | household_type_by_children12 == '1.5.2' | household_type_by_children12 == '2.2.0' replace household_type_by_children12 = '2 With older children' if household_type_by_children12 == '1.4.1' | household_type_by_children12 == '1.4.2' | household_type_by_children12 == '1.6.1' | household_type_by_children12 == '1.6.2' | household_type_by_children12 == '2.3.0' replace household_type_by_children12 = '3 With adult children' if household_type_by_children12 == '1.7.1' | household_type_by_children12 == '1.7.2' | household_type_by_children12 == '1.7.3' | household_type_by_children12 == '1.7.4' tabulate household_type_by_children12, missing merge household_type_by_children12 into household_DS_all on PERSONID_1 generate type_have_children12 = 0 replace type_have_children12 = 1 if household_type12 == '1.3.1' | household_type12 == '1.3.2' | household_type12 == '1.5.1' | household_type12 == '1.5.2' | household_type12 == '2.2.0' | household_type12 == '1.4.1' | household_type12 == '1.4.2' | household_type12 == '1.6.1' | household_type12 == '1.6.2' | household_type12 == '2.3.0' | household_type12 == '1.7.1' | household_type12 == '1.7.2' | household_type12 == '1.7.3' | household_type12 == '1.7.4' tabulate type_have_children12, missing merge type_have_children12 into household_DS_all on PERSONID_1 delete-dataset household_DS_type12 // Household type by children 2013 clone-dataset person_DS_Y13 household_DS_type13 use household_DS_type13 import db/BEFOLKNING_REGSTAT_HUSHTYP 2013-01-01 as household_type13 assign-labels household_type13 household_type_txt generate household_type_by_children13 = household_type13 replace household_type_by_children13 = '0 Without children' if household_type_by_children13 == '1.1.1' | household_type_by_children13 == '1.1.2' | household_type_by_children13 == '1.1.3' | household_type_by_children13 == '1.1.4' | household_type_by_children13 == '1.2.1' | household_type_by_children13 == '1.2.2' | household_type_by_children13 == '1.2.3' | household_type_by_children13 == '1.2.4' | household_type_by_children13 == '2.1.1' | household_type_by_children13 == '2.1.2' replace household_type_by_children13 = '1 With small children' if household_type_by_children13 == '1.3.1' | household_type_by_children13 == '1.3.2' | household_type_by_children13 == '1.5.1' | household_type_by_children13 == '1.5.2' | household_type_by_children13 == '2.2.0' replace household_type_by_children13 = '2 With older children' if household_type_by_children13 == '1.4.1' | household_type_by_children13 == '1.4.2' | household_type_by_children13 == '1.6.1' | household_type_by_children13 == '1.6.2' | household_type_by_children13 == '2.3.0' replace household_type_by_children13 = '3 With adult children' if household_type_by_children13 == '1.7.1' | household_type_by_children13 == '1.7.2' | household_type_by_children13 == '1.7.3' | household_type_by_children13 == '1.7.4' tabulate household_type_by_children13, missing merge household_type_by_children13 into household_DS_all on PERSONID_1 generate type_have_children13 = 0 replace type_have_children13 = 1 if household_type13 == '1.3.1' | household_type13 == '1.3.2' | household_type13 == '1.5.1' | household_type13 == '1.5.2' | household_type13 == '2.2.0' | household_type13 == '1.4.1' | household_type13 == '1.4.2' | household_type13 == '1.6.1' | household_type13 == '1.6.2' | household_type13 == '2.3.0' | household_type13 == '1.7.1' | household_type13 == '1.7.2' | household_type13 == '1.7.3' | household_type13 == '1.7.4' tabulate type_have_children13, missing merge type_have_children13 into household_DS_all on PERSONID_1 delete-dataset household_DS_type13 // Household type by children 2014 clone-dataset person_DS_Y14 household_DS_type14 use household_DS_type14 import db/BEFOLKNING_REGSTAT_HUSHTYP 2014-01-01 as household_type14 assign-labels household_type14 household_type_txt generate household_type_by_children14 = household_type14 replace household_type_by_children14 = '0 Without children' if household_type_by_children14 == '1.1.1' | household_type_by_children14 == '1.1.2' | household_type_by_children14 == '1.1.3' | household_type_by_children14 == '1.1.4' | household_type_by_children14 == '1.2.1' | household_type_by_children14 == '1.2.2' | household_type_by_children14 == '1.2.3' | household_type_by_children14 == '1.2.4' | household_type_by_children14 == '2.1.1' | household_type_by_children14 == '2.1.2' replace household_type_by_children14 = '1 With small children' if household_type_by_children14 == '1.3.1' | household_type_by_children14 == '1.3.2' | household_type_by_children14 == '1.5.1' | household_type_by_children14 == '1.5.2' | household_type_by_children14 == '2.2.0' replace household_type_by_children14 = '2 With older children' if household_type_by_children14 == '1.4.1' | household_type_by_children14 == '1.4.2' | household_type_by_children14 == '1.6.1' | household_type_by_children14 == '1.6.2' | household_type_by_children14 == '2.3.0' replace household_type_by_children14 = '3 With adult children' if household_type_by_children14 == '1.7.1' | household_type_by_children14 == '1.7.2' | household_type_by_children14 == '1.7.3' | household_type_by_children14 == '1.7.4' tabulate household_type_by_children14, missing merge household_type_by_children14 into household_DS_all on PERSONID_1 generate type_have_children14 = 0 replace type_have_children14 = 1 if household_type14 == '1.3.1' | household_type14 == '1.3.2' | household_type14 == '1.5.1' | household_type14 == '1.5.2' | household_type14 == '2.2.0' | household_type14 == '1.4.1' | household_type14 == '1.4.2' | household_type14 == '1.6.1' | household_type14 == '1.6.2' | household_type14 == '2.3.0' | household_type14 == '1.7.1' | household_type14 == '1.7.2' | household_type14 == '1.7.3' | household_type14 == '1.7.4' tabulate type_have_children14, missing merge type_have_children14 into household_DS_all on PERSONID_1 delete-dataset household_DS_type14 // Household type by children 2015 clone-dataset person_DS_Y15 household_DS_type15 use household_DS_type15 import db/BEFOLKNING_REGSTAT_HUSHTYP 2015-01-01 as household_type15 assign-labels household_type15 household_type_txt generate household_type_by_children15 = household_type15 replace household_type_by_children15 = '0 Without children' if household_type_by_children15 == '1.1.1' | household_type_by_children15 == '1.1.2' | household_type_by_children15 == '1.1.3' | household_type_by_children15 == '1.1.4' | household_type_by_children15 == '1.2.1' | household_type_by_children15 == '1.2.2' | household_type_by_children15 == '1.2.3' | household_type_by_children15 == '1.2.4' | household_type_by_children15 == '2.1.1' | household_type_by_children15 == '2.1.2' replace household_type_by_children15 = '1 With small children' if household_type_by_children15 == '1.3.1' | household_type_by_children15 == '1.3.2' | household_type_by_children15 == '1.5.1' | household_type_by_children15 == '1.5.2' | household_type_by_children15 == '2.2.0' replace household_type_by_children15 = '2 With older children' if household_type_by_children15 == '1.4.1' | household_type_by_children15 == '1.4.2' | household_type_by_children15 == '1.6.1' | household_type_by_children15 == '1.6.2' | household_type_by_children15 == '2.3.0' replace household_type_by_children15 = '3 With adult children' if household_type_by_children15 == '1.7.1' | household_type_by_children15 == '1.7.2' | household_type_by_children15 == '1.7.3' | household_type_by_children15 == '1.7.4' tabulate household_type_by_children15, missing merge household_type_by_children15 into household_DS_all on PERSONID_1 generate type_have_children15 = 0 replace type_have_children15 = 1 if household_type15 == '1.3.1' | household_type15 == '1.3.2' | household_type15 == '1.5.1' | household_type15 == '1.5.2' | household_type15 == '2.2.0' | household_type15 == '1.4.1' | household_type15 == '1.4.2' | household_type15 == '1.6.1' | household_type15 == '1.6.2' | household_type15 == '2.3.0' | household_type15 == '1.7.1' | household_type15 == '1.7.2' | household_type15 == '1.7.3' | household_type15 == '1.7.4' tabulate type_have_children15, missing merge type_have_children15 into household_DS_all on PERSONID_1 delete-dataset household_DS_type15 // Household type by children 2016 clone-dataset person_DS_Y16 household_DS_type16 use household_DS_type16 import db/BEFOLKNING_REGSTAT_HUSHTYP 2016-01-01 as household_type16 assign-labels household_type16 household_type_txt generate household_type_by_children16 = household_type16 replace household_type_by_children16 = '0 Without children' if household_type_by_children16 == '1.1.1' | household_type_by_children16 == '1.1.2' | household_type_by_children16 == '1.1.3' | household_type_by_children16 == '1.1.4' | household_type_by_children16 == '1.2.1' | household_type_by_children16 == '1.2.2' | household_type_by_children16 == '1.2.3' | household_type_by_children16 == '1.2.4' | household_type_by_children16 == '2.1.1' | household_type_by_children16 == '2.1.2' replace household_type_by_children16 = '1 With small children' if household_type_by_children16 == '1.3.1' | household_type_by_children16 == '1.3.2' | household_type_by_children16 == '1.5.1' | household_type_by_children16 == '1.5.2' | household_type_by_children16 == '2.2.0' replace household_type_by_children16 = '2 With older children' if household_type_by_children16 == '1.4.1' | household_type_by_children16 == '1.4.2' | household_type_by_children16 == '1.6.1' | household_type_by_children16 == '1.6.2' | household_type_by_children16 == '2.3.0' replace household_type_by_children16 = '3 With adult children' if household_type_by_children16 == '1.7.1' | household_type_by_children16 == '1.7.2' | household_type_by_children16 == '1.7.3' | household_type_by_children16 == '1.7.4' tabulate household_type_by_children16, missing merge household_type_by_children16 into household_DS_all on PERSONID_1 generate type_have_children16 = 0 replace type_have_children16 = 1 if household_type16 == '1.3.1' | household_type16 == '1.3.2' | household_type16 == '1.5.1' | household_type16 == '1.5.2' | household_type16 == '2.2.0' | household_type16 == '1.4.1' | household_type16 == '1.4.2' | household_type16 == '1.6.1' | household_type16 == '1.6.2' | household_type16 == '2.3.0' | household_type16 == '1.7.1' | household_type16 == '1.7.2' | household_type16 == '1.7.3' | household_type16 == '1.7.4' tabulate type_have_children16, missing merge type_have_children16 into household_DS_all on PERSONID_1 delete-dataset household_DS_type16 // Household type by children 2017 clone-dataset person_DS_Y17 household_DS_type17 use household_DS_type17 import db/BEFOLKNING_REGSTAT_HUSHTYP 2017-01-01 as household_type17 assign-labels household_type17 household_type_txt generate household_type_by_children17 = household_type17 replace household_type_by_children17 = '0 Without children' if household_type_by_children17 == '1.1.1' | household_type_by_children17 == '1.1.2' | household_type_by_children17 == '1.1.3' | household_type_by_children17 == '1.1.4' | household_type_by_children17 == '1.2.1' | household_type_by_children17 == '1.2.2' | household_type_by_children17 == '1.2.3' | household_type_by_children17 == '1.2.4' | household_type_by_children17 == '2.1.1' | household_type_by_children17 == '2.1.2' replace household_type_by_children17 = '1 With small children' if household_type_by_children17 == '1.3.1' | household_type_by_children17 == '1.3.2' | household_type_by_children17 == '1.5.1' | household_type_by_children17 == '1.5.2' | household_type_by_children17 == '2.2.0' replace household_type_by_children17 = '2 With older children' if household_type_by_children17 == '1.4.1' | household_type_by_children17 == '1.4.2' | household_type_by_children17 == '1.6.1' | household_type_by_children17 == '1.6.2' | household_type_by_children17 == '2.3.0' replace household_type_by_children17 = '3 With adult children' if household_type_by_children17 == '1.7.1' | household_type_by_children17 == '1.7.2' | household_type_by_children17 == '1.7.3' | household_type_by_children17 == '1.7.4' tabulate household_type_by_children17, missing merge household_type_by_children17 into household_DS_all on PERSONID_1 generate type_have_children17 = 0 replace type_have_children17 = 1 if household_type17 == '1.3.1' | household_type17 == '1.3.2' | household_type17 == '1.5.1' | household_type17 == '1.5.2' | household_type17 == '2.2.0' | household_type17 == '1.4.1' | household_type17 == '1.4.2' | household_type17 == '1.6.1' | household_type17 == '1.6.2' | household_type17 == '2.3.0' | household_type17 == '1.7.1' | household_type17 == '1.7.2' | household_type17 == '1.7.3' | household_type17 == '1.7.4' tabulate type_have_children17, missing merge type_have_children17 into household_DS_all on PERSONID_1 delete-dataset household_DS_type17 // Household type by children 2018 clone-dataset person_DS_Y18 household_DS_type18 use household_DS_type18 import db/BEFOLKNING_REGSTAT_HUSHTYP 2018-01-01 as household_type18 assign-labels household_type18 household_type_txt generate household_type_by_children18 = household_type18 replace household_type_by_children18 = '0 Without children' if household_type_by_children18 == '1.1.1' | household_type_by_children18 == '1.1.2' | household_type_by_children18 == '1.1.3' | household_type_by_children18 == '1.1.4' | household_type_by_children18 == '1.2.1' | household_type_by_children18 == '1.2.2' | household_type_by_children18 == '1.2.3' | household_type_by_children18 == '1.2.4' | household_type_by_children18 == '2.1.1' | household_type_by_children18 == '2.1.2' replace household_type_by_children18 = '1 With small children' if household_type_by_children18 == '1.3.1' | household_type_by_children18 == '1.3.2' | household_type_by_children18 == '1.5.1' | household_type_by_children18 == '1.5.2' | household_type_by_children18 == '2.2.0' replace household_type_by_children18 = '2 With older children' if household_type_by_children18 == '1.4.1' | household_type_by_children18 == '1.4.2' | household_type_by_children18 == '1.6.1' | household_type_by_children18 == '1.6.2' | household_type_by_children18 == '2.3.0' replace household_type_by_children18 = '3 With adult children' if household_type_by_children18 == '1.7.1' | household_type_by_children18 == '1.7.2' | household_type_by_children18 == '1.7.3' | household_type_by_children18 == '1.7.4' tabulate household_type_by_children18, missing merge household_type_by_children18 into household_DS_all on PERSONID_1 generate type_have_children18 = 0 replace type_have_children18 = 1 if household_type18 == '1.3.1' | household_type18 == '1.3.2' | household_type18 == '1.5.1' | household_type18 == '1.5.2' | household_type18 == '2.2.0' | household_type18 == '1.4.1' | household_type18 == '1.4.2' | household_type18 == '1.6.1' | household_type18 == '1.6.2' | household_type18 == '2.3.0' | household_type18 == '1.7.1' | household_type18 == '1.7.2' | household_type18 == '1.7.3' | household_type18 == '1.7.4' tabulate type_have_children18, missing merge type_have_children18 into household_DS_all on PERSONID_1 delete-dataset household_DS_type18 // Household type by children 2019 clone-dataset person_DS_Y19 household_DS_type19 use household_DS_type19 import db/BEFOLKNING_REGSTAT_HUSHTYP 2019-01-01 as household_type19 assign-labels household_type19 household_type_txt generate household_type_by_children19 = household_type19 replace household_type_by_children19 = '0 Without children' if household_type_by_children19 == '1.1.1' | household_type_by_children19 == '1.1.2' | household_type_by_children19 == '1.1.3' | household_type_by_children19 == '1.1.4' | household_type_by_children19 == '1.2.1' | household_type_by_children19 == '1.2.2' | household_type_by_children19 == '1.2.3' | household_type_by_children19 == '1.2.4' | household_type_by_children19 == '2.1.1' | household_type_by_children19 == '2.1.2' replace household_type_by_children19 = '1 With small children' if household_type_by_children19 == '1.3.1' | household_type_by_children19 == '1.3.2' | household_type_by_children19 == '1.5.1' | household_type_by_children19 == '1.5.2' | household_type_by_children19 == '2.2.0' replace household_type_by_children19 = '2 With older children' if household_type_by_children19 == '1.4.1' | household_type_by_children19 == '1.4.2' | household_type_by_children19 == '1.6.1' | household_type_by_children19 == '1.6.2' | household_type_by_children19 == '2.3.0' replace household_type_by_children19 = '3 With adult children' if household_type_by_children19 == '1.7.1' | household_type_by_children19 == '1.7.2' | household_type_by_children19 == '1.7.3' | household_type_by_children19 == '1.7.4' tabulate household_type_by_children19, missing merge household_type_by_children19 into household_DS_all on PERSONID_1 generate type_have_children19 = 0 replace type_have_children19 = 1 if household_type19 == '1.3.1' | household_type19 == '1.3.2' | household_type19 == '1.5.1' | household_type19 == '1.5.2' | household_type19 == '2.2.0' | household_type19 == '1.4.1' | household_type19 == '1.4.2' | household_type19 == '1.6.1' | household_type19 == '1.6.2' | household_type19 == '2.3.0' | household_type19 == '1.7.1' | household_type19 == '1.7.2' | household_type19 == '1.7.3' | household_type19 == '1.7.4' tabulate type_have_children19, missing merge type_have_children19 into household_DS_all on PERSONID_1 delete-dataset household_DS_type19 // Household type by children 2020 clone-dataset person_DS_Y20 household_DS_type20 use household_DS_type20 import db/BEFOLKNING_REGSTAT_HUSHTYP 2020-01-01 as household_type20 assign-labels household_type20 household_type_txt generate household_type_by_children20 = household_type20 replace household_type_by_children20 = '0 Without children' if household_type_by_children20 == '1.1.1' | household_type_by_children20 == '1.1.2' | household_type_by_children20 == '1.1.3' | household_type_by_children20 == '1.1.4' | household_type_by_children20 == '1.2.1' | household_type_by_children20 == '1.2.2' | household_type_by_children20 == '1.2.3' | household_type_by_children20 == '1.2.4' | household_type_by_children20 == '2.1.1' | household_type_by_children20 == '2.1.2' replace household_type_by_children20 = '1 With small children' if household_type_by_children20 == '1.3.1' | household_type_by_children20 == '1.3.2' | household_type_by_children20 == '1.5.1' | household_type_by_children20 == '1.5.2' | household_type_by_children20 == '2.2.0' replace household_type_by_children20 = '2 With older children' if household_type_by_children20 == '1.4.1' | household_type_by_children20 == '1.4.2' | household_type_by_children20 == '1.6.1' | household_type_by_children20 == '1.6.2' | household_type_by_children20 == '2.3.0' replace household_type_by_children20 = '3 With adult children' if household_type_by_children20 == '1.7.1' | household_type_by_children20 == '1.7.2' | household_type_by_children20 == '1.7.3' | household_type_by_children20 == '1.7.4' tabulate household_type_by_children20, missing merge household_type_by_children20 into household_DS_all on PERSONID_1 generate type_have_children20 = 0 replace type_have_children20 = 1 if household_type20 == '1.3.1' | household_type20 == '1.3.2' | household_type20 == '1.5.1' | household_type20 == '1.5.2' | household_type20 == '2.2.0' | household_type20 == '1.4.1' | household_type20 == '1.4.2' | household_type20 == '1.6.1' | household_type20 == '1.6.2' | household_type20 == '2.3.0' | household_type20 == '1.7.1' | household_type20 == '1.7.2' | household_type20 == '1.7.3' | household_type20 == '1.7.4' tabulate type_have_children20, missing merge type_have_children20 into household_DS_all on PERSONID_1 delete-dataset household_DS_type20 // Household type by children 2021 clone-dataset person_DS_Y21 household_DS_type21 use household_DS_type21 import db/BEFOLKNING_REGSTAT_HUSHTYP 2021-01-01 as household_type21 assign-labels household_type21 household_type_txt generate household_type_by_children21 = household_type21 replace household_type_by_children21 = '0 Without children' if household_type_by_children21 == '1.1.1' | household_type_by_children21 == '1.1.2' | household_type_by_children21 == '1.1.3' | household_type_by_children21 == '1.1.4' | household_type_by_children21 == '1.2.1' | household_type_by_children21 == '1.2.2' | household_type_by_children21 == '1.2.3' | household_type_by_children21 == '1.2.4' | household_type_by_children21 == '2.1.1' | household_type_by_children21 == '2.1.2' replace household_type_by_children21 = '1 With small children' if household_type_by_children21 == '1.3.1' | household_type_by_children21 == '1.3.2' | household_type_by_children21 == '1.5.1' | household_type_by_children21 == '1.5.2' | household_type_by_children21 == '2.2.0' replace household_type_by_children21 = '2 With older children' if household_type_by_children21 == '1.4.1' | household_type_by_children21 == '1.4.2' | household_type_by_children21 == '1.6.1' | household_type_by_children21 == '1.6.2' | household_type_by_children21 == '2.3.0' replace household_type_by_children21 = '3 With adult children' if household_type_by_children21 == '1.7.1' | household_type_by_children21 == '1.7.2' | household_type_by_children21 == '1.7.3' | household_type_by_children21 == '1.7.4' tabulate household_type_by_children21, missing merge household_type_by_children21 into household_DS_all on PERSONID_1 generate type_have_children21 = 0 replace type_have_children21 = 1 if household_type21 == '1.3.1' | household_type21 == '1.3.2' | household_type21 == '1.5.1' | household_type21 == '1.5.2' | household_type21 == '2.2.0' | household_type21 == '1.4.1' | household_type21 == '1.4.2' | household_type21 == '1.6.1' | household_type21 == '1.6.2' | household_type21 == '2.3.0' | household_type21 == '1.7.1' | household_type21 == '1.7.2' | household_type21 == '1.7.3' | household_type21 == '1.7.4' tabulate type_have_children21, missing merge type_have_children21 into household_DS_all on PERSONID_1 delete-dataset household_DS_type21 // Household type by children 2022 clone-dataset person_DS_Y22 household_DS_type22 use household_DS_type22 import db/BEFOLKNING_REGSTAT_HUSHTYP 2022-01-01 as household_type22 assign-labels household_type22 household_type_txt generate resident22 = 1 barchart(count) resident22, over(household_type22) generate household_type_by_children22 = household_type22 replace household_type_by_children22 = '0 Without children' if household_type_by_children22 == '1.1.1' | household_type_by_children22 == '1.1.2' | household_type_by_children22 == '1.1.3' | household_type_by_children22 == '1.1.4' | household_type_by_children22 == '1.2.1' | household_type_by_children22 == '1.2.2' | household_type_by_children22 == '1.2.3' | household_type_by_children22 == '1.2.4' | household_type_by_children22 == '2.1.1' | household_type_by_children22 == '2.1.2' replace household_type_by_children22 = '1 With small children' if household_type_by_children22 == '1.3.1' | household_type_by_children22 == '1.3.2' | household_type_by_children22 == '1.5.1' | household_type_by_children22 == '1.5.2' | household_type_by_children22 == '2.2.0' replace household_type_by_children22 = '2 With older children' if household_type_by_children22 == '1.4.1' | household_type_by_children22 == '1.4.2' | household_type_by_children22 == '1.6.1' | household_type_by_children22 == '1.6.2' | household_type_by_children22 == '2.3.0' replace household_type_by_children22 = '3 With adult children' if household_type_by_children22 == '1.7.1' | household_type_by_children22 == '1.7.2' | household_type_by_children22 == '1.7.3' | household_type_by_children22 == '1.7.4' tabulate household_type_by_children22, missing merge household_type_by_children22 into household_DS_all on PERSONID_1 generate type_have_children22 = 0 replace type_have_children22 = 1 if household_type22 == '1.3.1' | household_type22 == '1.3.2' | household_type22 == '1.5.1' | household_type22 == '1.5.2' | household_type22 == '2.2.0' | household_type22 == '1.4.1' | household_type22 == '1.4.2' | household_type22 == '1.6.1' | household_type22 == '1.6.2' | household_type22 == '2.3.0' | household_type22 == '1.7.1' | household_type22 == '1.7.2' | household_type22 == '1.7.3' | household_type22 == '1.7.4' tabulate type_have_children22, missing merge type_have_children22 into household_DS_all on PERSONID_1 delete-dataset household_DS_type22 textblock Urban Settlement ------------------ The urban settlement is also called this stage. ::::: There are three (3) categories of settlement: - s: a person not resident in an urban area (also it means, the person resident in scattered areas), - t: a person living in an urban area, - u: person unplaced in dense/scattered area, due to lack of coordinates. Note: In later steps, this data is aggregated at the household level. Note: data on urban settlement for 2010 is not available. https://microdata.no/discovery/variable/no.ssb.fdb/26/BEFOLKNING_TS_KODE?searchString=BEFOLKNING_TS_KODE endblock clone-dataset person_DS_Y05 household_DS_urban_settlement05 use household_DS_urban_settlement05 import db/BEFOLKNING_TS_KODE 2005-01-01 as urban_settlement05 define-labels urban_settlement_txt 's' nonUrban 't' Urban 'u' Unknown assign-labels urban_settlement05 urban_settlement_txt drop if urban_settlement05 == "u" // Drop missing "Unknown", i.e., missing values // Create an independent dummy variable for urbanism: "t" is urban. generate live_in_urban05 = 0 replace live_in_urban05 = 1 if urban_settlement05 == "t" piechart urban_settlement05 merge live_in_urban05 into household_DS_all on PERSONID_1 delete-dataset household_DS_urban_settlement05 clone-dataset person_DS_Y06 household_DS_urban_settlement06 use household_DS_urban_settlement06 import db/BEFOLKNING_TS_KODE 2006-01-01 as urban_settlement06 assign-labels urban_settlement06 urban_settlement_txt drop if urban_settlement06 == "u" generate live_in_urban06 = 0 replace live_in_urban06 = 1 if urban_settlement06 == "t" merge live_in_urban06 into household_DS_all on PERSONID_1 delete-dataset household_DS_urban_settlement06 clone-dataset person_DS_Y07 household_DS_urban_settlement07 use household_DS_urban_settlement07 import db/BEFOLKNING_TS_KODE 2007-01-01 as urban_settlement07 assign-labels urban_settlement07 urban_settlement_txt drop if urban_settlement07 == "u" generate live_in_urban07 = 0 replace live_in_urban07 = 1 if urban_settlement07 == "t" merge live_in_urban07 into household_DS_all on PERSONID_1 delete-dataset household_DS_urban_settlement07 clone-dataset person_DS_Y08 household_DS_urban_settlement08 use household_DS_urban_settlement08 import db/BEFOLKNING_TS_KODE 2008-01-01 as urban_settlement08 assign-labels urban_settlement08 urban_settlement_txt drop if urban_settlement08 == "u" generate live_in_urban08 = 0 replace live_in_urban08 = 1 if urban_settlement08 == "t" merge live_in_urban08 into household_DS_all on PERSONID_1 delete-dataset household_DS_urban_settlement08 clone-dataset person_DS_Y09 household_DS_urban_settlement09 use household_DS_urban_settlement09 import db/BEFOLKNING_TS_KODE 2009-01-01 as urban_settlement09 assign-labels urban_settlement09 urban_settlement_txt drop if urban_settlement09 == "u" generate live_in_urban09 = 0 replace live_in_urban09 = 1 if urban_settlement09 == "t" merge live_in_urban09 into household_DS_all on PERSONID_1 delete-dataset household_DS_urban_settlement09 // #Note that data on urban settlement for 2010 is not available. https://microdata.no/discovery/variable/no.ssb.fdb/19/BEFOLKNING_TS_KODE?searchString=BEFOLKNING_TS_KODE //clone-dataset person_DS_Y10 household_DS_urban_settlement10 //use household_DS_urban_settlement10 //generate live_in_urban10 = 0 //merge live_in_urban10 into household_DS_all on PERSONID_1 //delete-dataset household_DS_urban_settlement10 clone-dataset person_DS_Y11 household_DS_urban_settlement11 use household_DS_urban_settlement11 import db/BEFOLKNING_TS_KODE 2011-01-01 as urban_settlement11 assign-labels urban_settlement11 urban_settlement_txt drop if urban_settlement11 == "u" generate live_in_urban11 = 0 replace live_in_urban11 = 1 if urban_settlement11 == "t" piechart urban_settlement11 merge live_in_urban11 into household_DS_all on PERSONID_1 delete-dataset household_DS_urban_settlement11 clone-dataset person_DS_Y12 household_DS_urban_settlement12 use household_DS_urban_settlement12 import db/BEFOLKNING_TS_KODE 2012-01-01 as urban_settlement12 assign-labels urban_settlement12 urban_settlement_txt drop if urban_settlement12 == "u" generate live_in_urban12 = 0 replace live_in_urban12 = 1 if urban_settlement12 == "t" merge live_in_urban12 into household_DS_all on PERSONID_1 delete-dataset household_DS_urban_settlement12 clone-dataset person_DS_Y13 household_DS_urban_settlement13 use household_DS_urban_settlement13 import db/BEFOLKNING_TS_KODE 2013-01-01 as urban_settlement13 assign-labels urban_settlement13 urban_settlement_txt drop if urban_settlement13 == "u" generate live_in_urban13 = 0 replace live_in_urban13 = 1 if urban_settlement13 == "t" merge live_in_urban13 into household_DS_all on PERSONID_1 delete-dataset household_DS_urban_settlement13 clone-dataset person_DS_Y14 household_DS_urban_settlement14 use household_DS_urban_settlement14 import db/BEFOLKNING_TS_KODE 2014-01-01 as urban_settlement14 assign-labels urban_settlement14 urban_settlement_txt drop if urban_settlement14 == "u" generate live_in_urban14 = 0 replace live_in_urban14 = 1 if urban_settlement14 == "t" merge live_in_urban14 into household_DS_all on PERSONID_1 delete-dataset household_DS_urban_settlement14 clone-dataset person_DS_Y15 household_DS_urban_settlement15 use household_DS_urban_settlement15 import db/BEFOLKNING_TS_KODE 2015-01-01 as urban_settlement15 assign-labels urban_settlement15 urban_settlement_txt drop if urban_settlement15 == "u" generate live_in_urban15 = 0 replace live_in_urban15 = 1 if urban_settlement15 == "t" merge live_in_urban15 into household_DS_all on PERSONID_1 delete-dataset household_DS_urban_settlement15 clone-dataset person_DS_Y16 household_DS_urban_settlement16 use household_DS_urban_settlement16 import db/BEFOLKNING_TS_KODE 2016-01-01 as urban_settlement16 assign-labels urban_settlement16 urban_settlement_txt drop if urban_settlement16 == "u" generate live_in_urban16 = 0 replace live_in_urban16 = 1 if urban_settlement16 == "t" piechart urban_settlement16 merge live_in_urban16 into household_DS_all on PERSONID_1 delete-dataset household_DS_urban_settlement16 clone-dataset person_DS_Y17 household_DS_urban_settlement17 use household_DS_urban_settlement17 import db/BEFOLKNING_TS_KODE 2017-01-01 as urban_settlement17 assign-labels urban_settlement17 urban_settlement_txt drop if urban_settlement17 == "u" generate live_in_urban17 = 0 replace live_in_urban17 = 1 if urban_settlement17 == "t" merge live_in_urban17 into household_DS_all on PERSONID_1 delete-dataset household_DS_urban_settlement17 clone-dataset person_DS_Y18 household_DS_urban_settlement18 use household_DS_urban_settlement18 import db/BEFOLKNING_TS_KODE 2018-01-01 as urban_settlement18 assign-labels urban_settlement18 urban_settlement_txt drop if urban_settlement18 == "u" generate live_in_urban18 = 0 replace live_in_urban18 = 1 if urban_settlement18 == "t" merge live_in_urban18 into household_DS_all on PERSONID_1 delete-dataset household_DS_urban_settlement18 clone-dataset person_DS_Y19 household_DS_urban_settlement19 use household_DS_urban_settlement19 import db/BEFOLKNING_TS_KODE 2019-01-01 as urban_settlement19 assign-labels urban_settlement19 urban_settlement_txt drop if urban_settlement19 == "u" generate live_in_urban19 = 0 replace live_in_urban19 = 1 if urban_settlement19 == "t" merge live_in_urban19 into household_DS_all on PERSONID_1 delete-dataset household_DS_urban_settlement19 clone-dataset person_DS_Y20 household_DS_urban_settlement20 use household_DS_urban_settlement20 import db/BEFOLKNING_TS_KODE 2020-01-01 as urban_settlement20 assign-labels urban_settlement20 urban_settlement_txt drop if urban_settlement20 == "u" generate live_in_urban20 = 0 replace live_in_urban20 = 1 if urban_settlement20 == "t" merge live_in_urban20 into household_DS_all on PERSONID_1 delete-dataset household_DS_urban_settlement20 clone-dataset person_DS_Y21 household_DS_urban_settlement21 use household_DS_urban_settlement21 import db/BEFOLKNING_TS_KODE 2021-01-01 as urban_settlement21 assign-labels urban_settlement21 urban_settlement_txt drop if urban_settlement21 == "u" generate live_in_urban21 = 0 replace live_in_urban21 = 1 if urban_settlement21 == "t" merge live_in_urban21 into household_DS_all on PERSONID_1 delete-dataset household_DS_urban_settlement21 clone-dataset person_DS_Y22 household_DS_urban_settlement22 use household_DS_urban_settlement22 import db/BEFOLKNING_TS_KODE 2022-01-01 as urban_settlement22 assign-labels urban_settlement22 urban_settlement_txt drop if urban_settlement22 == "u" generate live_in_urban22 = 0 replace live_in_urban22 = 1 if urban_settlement22 == "t" merge live_in_urban22 into household_DS_all on PERSONID_1 delete-dataset household_DS_urban_settlement22 // Do some housekeeping: delete datasets that are no longer needed. delete-dataset person_DS_Y05 delete-dataset person_DS_Y06 delete-dataset person_DS_Y07 delete-dataset person_DS_Y08 delete-dataset person_DS_Y09 delete-dataset person_DS_Y10 delete-dataset person_DS_Y11 delete-dataset person_DS_Y12 delete-dataset person_DS_Y13 delete-dataset person_DS_Y14 delete-dataset person_DS_Y15 delete-dataset person_DS_Y16 delete-dataset person_DS_Y17 delete-dataset person_DS_Y18 delete-dataset person_DS_Y19 delete-dataset person_DS_Y20 delete-dataset person_DS_Y21 delete-dataset person_DS_Y22 use household_DS_all // We generate natural logarithm of income in this step. To avoid missing values generated by the natural logarithm transformation, negative values of income are set to 1. summarize household_income05 if household_income05 <= 0 replace household_income05 = 1 if household_income05 <= 0 generate household_income_natlog05 = ln(household_income05) summarize household_income06 if household_income06 <= 0 replace household_income06 = 1 if household_income06 <= 0 generate household_income_natlog06 = ln(household_income06) summarize household_income07 if household_income07 <= 0 replace household_income07 = 1 if household_income07 <= 0 generate household_income_natlog07 = ln(household_income07) summarize household_income08 if household_income08 <= 0 replace household_income08 = 1 if household_income08 <= 0 generate household_income_natlog08 = ln(household_income08) summarize household_income09 if household_income09 <= 0 replace household_income09 = 1 if household_income09 <= 0 generate household_income_natlog09 = ln(household_income09) summarize household_income10 if household_income10 <= 0 replace household_income10 = 1 if household_income10 <= 0 generate household_income_natlog10 = ln(household_income10) summarize household_income11 if household_income11 <= 0 replace household_income11 = 1 if household_income11 <= 0 generate household_income_natlog11 = ln(household_income11) summarize household_income12 if household_income12 <= 0 replace household_income12 = 1 if household_income12 <= 0 generate household_income_natlog12 = ln(household_income12) summarize household_income13 if household_income13 <= 0 replace household_income13 = 1 if household_income13 <= 0 generate household_income_natlog13 = ln(household_income13) summarize household_income14 if household_income14 <= 0 replace household_income14 = 1 if household_income14 <= 0 generate household_income_natlog14 = ln(household_income14) summarize household_income15 if household_income15 <= 0 replace household_income15 = 1 if household_income15 <= 0 generate household_income_natlog15 = ln(household_income15) summarize household_income16 if household_income16 <= 0 replace household_income16 = 1 if household_income16 <= 0 generate household_income_natlog16 = ln(household_income16) summarize household_income17 if household_income17 <= 0 replace household_income17 = 1 if household_income17 <= 0 generate household_income_natlog17 = ln(household_income17) summarize household_income18 if household_income18 <= 0 replace household_income18 = 1 if household_income18 <= 0 generate household_income_natlog18 = ln(household_income18) summarize household_income19 if household_income19 <= 0 replace household_income19 = 1 if household_income19 <= 0 generate household_income_natlog19 = ln(household_income19) summarize household_income20 if household_income20 <= 0 replace household_income20 = 1 if household_income20 <= 0 generate household_income_natlog20 = ln(household_income20) summarize household_income21 if household_income21 <= 0 replace household_income21 = 1 if household_income21 <= 0 generate household_income_natlog21 = ln(household_income21) //summarize household_income22 if household_income22 <= 0 //replace household_income22 = 1 if household_income22 <= 0 //generate household_income_natlog22 = ln(household_income22) // For the Green panel data clone-dataset household_DS_all household_DS_2005_2022_atleast_once_green_owners_wide // For the Gray descriptive analysis clone-dataset household_DS_all household_DS_2005_2022_always_gray_owners_wide // Continue with the Green panel data // Streamling of the forked dataset "Green": Keep any "once_owner" household who ever owned any green vehicle over the period... use household_DS_2005_2022_atleast_once_green_owners_wide keep if owned_vehicle_green_per_household05 >= 1 | owned_vehicle_green_per_household06 >= 1 | owned_vehicle_green_per_household07 >= 1 | owned_vehicle_green_per_household08 >= 1 | owned_vehicle_green_per_household09 >= 1 | owned_vehicle_green_per_household10 >= 1 | owned_vehicle_green_per_household11 >= 1 | owned_vehicle_green_per_household12 >= 1 | owned_vehicle_green_per_household13 >= 1 | owned_vehicle_green_per_household14 >= 1 | owned_vehicle_green_per_household15 >= 1 | owned_vehicle_green_per_household16 >= 1 | owned_vehicle_green_per_household17 >= 1 | owned_vehicle_green_per_household18 >= 1 | owned_vehicle_green_per_household19 >= 1 | owned_vehicle_green_per_household20 >= 1 | owned_vehicle_green_per_household21 >= 1 | owned_vehicle_green_per_household22 >= 1 // For the Green descriptive analysis clone-dataset household_DS_2005_2022_atleast_once_green_owners_wide household_DS_2005_2022_atleast_once_green_owners_descriptive // The following is not needed for the green panel. use household_DS_2005_2022_atleast_once_green_owners_wide drop owned_vehicle_gray_per_household05 drop owned_vehicle_gray_per_household06 drop owned_vehicle_gray_per_household07 drop owned_vehicle_gray_per_household08 drop owned_vehicle_gray_per_household09 drop owned_vehicle_gray_per_household10 drop owned_vehicle_gray_per_household11 drop owned_vehicle_gray_per_household12 drop owned_vehicle_gray_per_household13 drop owned_vehicle_gray_per_household14 drop owned_vehicle_gray_per_household15 drop owned_vehicle_gray_per_household16 drop owned_vehicle_gray_per_household17 drop owned_vehicle_gray_per_household18 drop owned_vehicle_gray_per_household19 drop owned_vehicle_gray_per_household20 drop owned_vehicle_gray_per_household21 drop owned_vehicle_gray_per_household22 drop owned_vehicle_all_per_household05 drop owned_vehicle_all_per_household06 drop owned_vehicle_all_per_household07 drop owned_vehicle_all_per_household08 drop owned_vehicle_all_per_household09 drop owned_vehicle_all_per_household10 drop owned_vehicle_all_per_household11 drop owned_vehicle_all_per_household12 drop owned_vehicle_all_per_household13 drop owned_vehicle_all_per_household14 drop owned_vehicle_all_per_household15 drop owned_vehicle_all_per_household16 drop owned_vehicle_all_per_household17 drop owned_vehicle_all_per_household18 drop owned_vehicle_all_per_household19 drop owned_vehicle_all_per_household20 drop owned_vehicle_all_per_household21 drop owned_vehicle_all_per_household22 // income, wealth and debt in NOK, and a detailed household_type_by_children are not needed for this panel data anlysis. drop household_income05 drop household_income06 drop household_income07 drop household_income08 drop household_income09 drop household_income10 drop household_income11 drop household_income12 drop household_income13 drop household_income14 drop household_income15 drop household_income16 drop household_income17 drop household_income18 drop household_income19 drop household_income20 drop household_income21 //drop household_income22 drop household_wealth05 drop household_wealth06 drop household_wealth07 drop household_wealth08 drop household_wealth09 drop household_wealth10 drop household_wealth11 drop household_wealth12 drop household_wealth13 drop household_wealth14 drop household_wealth15 drop household_wealth16 drop household_wealth17 drop household_wealth18 drop household_wealth19 drop household_wealth20 //drop household_wealth21 //drop household_wealth22 drop household_debt05 drop household_debt06 drop household_debt07 drop household_debt08 drop household_debt09 drop household_debt10 drop household_debt11 drop household_debt12 drop household_debt13 drop household_debt14 drop household_debt15 drop household_debt16 drop household_debt17 drop household_debt18 drop household_debt19 drop household_debt20 drop household_debt21 //drop household_debt22 drop household_type_by_children05 drop household_type_by_children06 drop household_type_by_children07 drop household_type_by_children08 drop household_type_by_children09 drop household_type_by_children10 drop household_type_by_children11 drop household_type_by_children12 drop household_type_by_children13 drop household_type_by_children14 drop household_type_by_children15 drop household_type_by_children16 drop household_type_by_children17 drop household_type_by_children18 drop household_type_by_children19 drop household_type_by_children20 drop household_type_by_children21 drop household_type_by_children22 reshape-to-panel household_size household_background household_residence_work household_income_natlog household_highest_edu_numeric type_have_children live_in_urban owned_vehicle_green_per_household //A new streamling of the dataset: Any dissolved household over the time period should be dropped on years with missing data. drop if sysmiss(household_size) tabulate live_in_urban if date@panel == 10 // Urban data for 2010 and income data for 2022 is not reported in v.26. So, we drop all data fror these years from the panel regression analysis. use household_DS_2005_2022_atleast_once_green_owners_wide drop if date@panel == 10 drop if date@panel == 22 drop if sysmiss(household_size) // For the Gray panel data analysis // Streamling of the forked dataset "gray": Drop any "once_owner" household who ever owned any green vehicle over the period... use household_DS_2005_2022_always_gray_owners_wide drop if owned_vehicle_green_per_household05 >= 1 | owned_vehicle_green_per_household06 >= 1 | owned_vehicle_green_per_household07 >= 1 | owned_vehicle_green_per_household08 >= 1 | owned_vehicle_green_per_household09 >= 1 | owned_vehicle_green_per_household10 >= 1 | owned_vehicle_green_per_household11 >= 1 | owned_vehicle_green_per_household12 >= 1 | owned_vehicle_green_per_household13 >= 1 | owned_vehicle_green_per_household14 >= 1 | owned_vehicle_green_per_household15 >= 1 | owned_vehicle_green_per_household16 >= 1 | owned_vehicle_green_per_household17 >= 1 | owned_vehicle_green_per_household18 >= 1 | owned_vehicle_green_per_household19 >= 1 | owned_vehicle_green_per_household20 >= 1 | owned_vehicle_green_per_household21 >= 1 | owned_vehicle_green_per_household22 >= 1 // For Gray descriptive analysis clone-dataset household_DS_2005_2022_always_gray_owners_wide household_DS_2005_2022_always_gray_owners_descriptive // Since this group have never had a green car, we can drop all owned_vehicle_green_per_household variables for Gray panel analysis. use household_DS_2005_2022_always_gray_owners_wide drop owned_vehicle_green_per_household05 drop owned_vehicle_green_per_household06 drop owned_vehicle_green_per_household07 drop owned_vehicle_green_per_household08 drop owned_vehicle_green_per_household09 drop owned_vehicle_green_per_household10 drop owned_vehicle_green_per_household11 drop owned_vehicle_green_per_household12 drop owned_vehicle_green_per_household13 drop owned_vehicle_green_per_household14 drop owned_vehicle_green_per_household15 drop owned_vehicle_green_per_household16 drop owned_vehicle_green_per_household17 drop owned_vehicle_green_per_household18 drop owned_vehicle_green_per_household19 drop owned_vehicle_green_per_household20 drop owned_vehicle_green_per_household21 drop owned_vehicle_green_per_household22 drop owned_vehicle_all_per_household05 drop owned_vehicle_all_per_household06 drop owned_vehicle_all_per_household07 drop owned_vehicle_all_per_household08 drop owned_vehicle_all_per_household09 drop owned_vehicle_all_per_household10 drop owned_vehicle_all_per_household11 drop owned_vehicle_all_per_household12 drop owned_vehicle_all_per_household13 drop owned_vehicle_all_per_household14 drop owned_vehicle_all_per_household15 drop owned_vehicle_all_per_household16 drop owned_vehicle_all_per_household17 drop owned_vehicle_all_per_household18 drop owned_vehicle_all_per_household19 drop owned_vehicle_all_per_household20 drop owned_vehicle_all_per_household21 drop owned_vehicle_all_per_household22 // Again, income, wealth and debt in NOK, and a detailed household_type_by_children are not needed for this panel data anlysis. drop household_income05 drop household_income06 drop household_income07 drop household_income08 drop household_income09 drop household_income10 drop household_income11 drop household_income12 drop household_income13 drop household_income14 drop household_income15 drop household_income16 drop household_income17 drop household_income18 drop household_income19 drop household_income20 drop household_income21 //drop household_income22 drop household_wealth05 drop household_wealth06 drop household_wealth07 drop household_wealth08 drop household_wealth09 drop household_wealth10 drop household_wealth11 drop household_wealth12 drop household_wealth13 drop household_wealth14 drop household_wealth15 drop household_wealth16 drop household_wealth17 drop household_wealth18 drop household_wealth19 drop household_wealth20 //drop household_wealth21 //drop household_wealth22 drop household_debt05 drop household_debt06 drop household_debt07 drop household_debt08 drop household_debt09 drop household_debt10 drop household_debt11 drop household_debt12 drop household_debt13 drop household_debt14 drop household_debt15 drop household_debt16 drop household_debt17 drop household_debt18 drop household_debt19 drop household_debt20 drop household_debt21 //drop household_debt22 drop household_type_by_children05 drop household_type_by_children06 drop household_type_by_children07 drop household_type_by_children08 drop household_type_by_children09 drop household_type_by_children10 drop household_type_by_children11 drop household_type_by_children12 drop household_type_by_children13 drop household_type_by_children14 drop household_type_by_children15 drop household_type_by_children16 drop household_type_by_children17 drop household_type_by_children18 drop household_type_by_children19 drop household_type_by_children20 drop household_type_by_children21 drop household_type_by_children22 reshape-to-panel household_size household_background household_residence_work household_income_natlog household_highest_edu_numeric type_have_children live_in_urban owned_vehicle_gray_per_household //A new streamling of the dataset: Any dissolved household over the time period should be dropped on years with missing data. drop if sysmiss(household_size) // Urban data for 2010 and income data for 2022 is not reported in v.26. So, we drop all data fror these years from the panel regression analysis. use household_DS_2005_2022_always_gray_owners_wide drop if date@panel == 10 drop if date@panel == 22 drop if sysmiss(household_size) textblock VIF and Tolerance ------- For Green endblock use household_DS_2005_2022_atleast_once_green_owners_descriptive regress owned_vehicle_green_per_household21 household_income_natlog21 household_size21 household_residence_work21 household_highest_edu_numeric21 type_have_children21 live_in_urban21 household_background21, vif textblock VIF and Tolerance ------- For Gray endblock use household_DS_2005_2022_always_gray_owners_descriptive regress owned_vehicle_gray_per_household21 household_income_natlog21 household_size21 household_residence_work21 household_highest_edu_numeric21 type_have_children21 live_in_urban21 household_background21, vif textblock some tests for instrument(s) ------- unrestricted vs restricted model endblock textblock For Green ------- unrestricted vs restricted model: results endblock use household_DS_2005_2022_atleast_once_green_owners_descriptive tabulate household_background21, missing piechart household_background21 histogram household_background21, freq // Unrestricted model for Green regress household_income_natlog21 household_size21 household_residence_work21 household_highest_edu_numeric21 type_have_children21 live_in_urban21 household_background21, het_iid het_fstat regress-predict household_income_natlog21 household_size21 household_residence_work21 household_highest_edu_numeric21 type_have_children21 live_in_urban21 household_background21, residuals(residuals_income_background_green) histogram residuals_income_background_green, normal correlate household_background21 residuals_income_background_green, sig drop residuals_income_background_green // No longer needed! // Restricted model for Green regress household_income_natlog21 household_size21 household_residence_work21 household_highest_edu_numeric21 type_have_children21 live_in_urban21, het_iid het_fstat textblock For Gray ------- unrestricted vs restricted model: results endblock use household_DS_2005_2022_always_gray_owners_descriptive tabulate household_background21, missing piechart household_background21 histogram household_background21, freq // Unrestricted model for Gray regress household_income_natlog21 household_size21 household_residence_work21 household_highest_edu_numeric21 type_have_children21 live_in_urban21 household_background21, het_iid het_fstat regress-predict household_income_natlog21 household_size21 household_residence_work21 household_highest_edu_numeric21 type_have_children21 live_in_urban21 household_background21, residuals(residuals_income_background_gray) histogram residuals_income_background_gray, normal correlate household_background21 residuals_income_background_gray, sig drop residuals_income_background_gray // No longer needed! // Restricted model for Gray regress household_income_natlog21 household_size21 household_residence_work21 household_highest_edu_numeric21 type_have_children21 live_in_urban21, het_iid het_fstat textblock The pairwise correlations ... ------- including the instrument(s). endblock textblock The pairwise correlations ... ------- endblock use household_DS_all // Year 2020 correlate owned_vehicle_all_per_household20 owned_vehicle_gray_per_household20 owned_vehicle_green_per_household20 household_size20 household_residence_work20 household_income20 household_income_natlog20 household_wealth20 household_debt20 household_highest_edu_numeric20 type_have_children20 live_in_urban20 household_background20, pairwise // Year 2021 correlate owned_vehicle_all_per_household21 owned_vehicle_gray_per_household21 owned_vehicle_green_per_household21 household_size21 household_residence_work21 household_income21 household_income_natlog21 household_highest_edu_numeric21 type_have_children21 live_in_urban21 household_background21, pairwise textblock The pairwise correlations ... ------- including the instrument(s): "at least once green owners" dataset endblock use household_DS_2005_2022_atleast_once_green_owners_descriptive // Year 2020 correlate owned_vehicle_green_per_household20 household_size20 household_residence_work20 household_income20 household_income_natlog20 household_wealth20 household_debt20 household_highest_edu_numeric20 type_have_children20 live_in_urban20 household_background20, pairwise correlate owned_vehicle_green_per_household20 household_background20, sig correlate household_income_natlog20 household_background20, sig correlate household_income20 household_background20, sig // Year 2021 correlate owned_vehicle_green_per_household21 household_size21 household_residence_work21 household_income21 household_income_natlog21 household_highest_edu_numeric21 type_have_children21 live_in_urban21 household_background21, pairwise correlate owned_vehicle_green_per_household21 household_background21, sig correlate household_income_natlog21 household_background21, sig correlate household_income21 household_background21, sig textblock The pairwise correlations ... ------- including the instrument(s): "always gray owners" dataset endblock use household_DS_2005_2022_always_gray_owners_descriptive // Year 2020 correlate owned_vehicle_gray_per_household20 household_size20 household_residence_work20 household_income20 household_income_natlog20 household_wealth20 household_debt20 household_highest_edu_numeric20 type_have_children20 live_in_urban20 household_background20, pairwise correlate owned_vehicle_gray_per_household20 household_background20, sig correlate household_income_natlog20 household_background20, sig correlate household_income20 household_background20, sig // Year 2021 correlate owned_vehicle_gray_per_household21 household_size21 household_residence_work21 household_income21 household_income_natlog21 household_highest_edu_numeric21 type_have_children21 live_in_urban21 household_background21, pairwise correlate owned_vehicle_gray_per_household21 household_background21, sig correlate household_income_natlog21 household_background21, sig correlate household_income21 household_background21, sig //use household_DS_2005_2022_always_gray_owners //generate some_results = invFtail(1,22251180,0.05) //tabulate some_results textblock Green vehicles ownership Panel Data: Ignoring income endogeneity --------------------------------------- 2005 to 2021 (except for 2010) endblock use household_DS_2005_2022_atleast_once_green_owners_wide // Perform hausman-test // dependent variable: Green vehicle ownership hausman owned_vehicle_green_per_household household_size household_residence_work household_income_natlog household_highest_edu_numeric type_have_children live_in_urban textblock IV regression: 1st stage for Green ------- "household background" is the instrument. endblock hausman household_income_natlog household_size household_residence_work household_highest_edu_numeric type_have_children live_in_urban household_background regress-panel household_income_natlog household_size household_residence_work household_highest_edu_numeric type_have_children live_in_urban household_background, fe regress-panel-predict household_income_natlog household_size household_residence_work household_highest_edu_numeric type_have_children live_in_urban household_background, fe predicted(household_income_natlog_HAT) residuals(residuals_income_natlog_stage1_green) histogram residuals_income_natlog_stage1_green, normal textblock IV regression: 2nd stage for Green ------- "household background" is the instrument. endblock hausman owned_vehicle_green_per_household household_size household_residence_work household_income_natlog_HAT household_highest_edu_numeric type_have_children live_in_urban textblock Gray vehicles ownership Panel Data: Ignoring income endogeneity --------------------------------------- 2005 to 2021 (except for 2010) endblock use household_DS_2005_2022_always_gray_owners_wide // Perform hausman-test // dependent variable: gray vehicle ownership hausman owned_vehicle_gray_per_household household_size household_residence_work household_income_natlog household_highest_edu_numeric type_have_children live_in_urban textblock IV regression: 1st stage for Gray ------- "household background" is the instrument. endblock hausman household_income_natlog household_size household_residence_work household_highest_edu_numeric type_have_children live_in_urban household_background regress-panel household_income_natlog household_size household_residence_work household_highest_edu_numeric type_have_children live_in_urban household_background, fe regress-panel-predict household_income_natlog household_size household_residence_work household_highest_edu_numeric type_have_children live_in_urban household_background, fe predicted(household_income_natlog_HAT) residuals(residuals_income_natlog_stage1_gray) histogram residuals_income_natlog_stage1_gray, normal textblock IV regression: 2nd stage for Gray ------- ... endblock hausman owned_vehicle_gray_per_household household_size household_residence_work household_income_natlog_HAT household_highest_edu_numeric type_have_children live_in_urban textblock Descriptive analysis for the paper: Green Adopters --------------------------------------- 2005 to 2022: An overview endblock use household_DS_2005_2022_atleast_once_green_owners_descriptive summarize household_income05 household_income06 household_income07 household_income08 household_income09 household_income10 household_income11 household_income12 household_income13 household_income14 household_income15 household_income16 household_income17 household_income18 household_income19 household_income20 household_income21 summarize household_wealth05 household_wealth06 household_wealth07 household_wealth08 household_wealth09 household_wealth10 household_wealth11 household_wealth12 household_wealth13 household_wealth14 household_wealth15 household_wealth16 household_wealth17 household_wealth18 household_wealth19 household_wealth20 summarize household_debt05 household_debt06 household_debt07 household_debt08 household_debt09 household_debt10 household_debt11 household_debt12 household_debt13 household_debt14 household_debt15 household_debt16 household_debt17 household_debt18 household_debt19 household_debt20 household_debt21 summarize household_highest_edu_numeric05 household_highest_edu_numeric06 household_highest_edu_numeric07 household_highest_edu_numeric08 household_highest_edu_numeric09 household_highest_edu_numeric10 household_highest_edu_numeric11 household_highest_edu_numeric12 household_highest_edu_numeric13 household_highest_edu_numeric14 household_highest_edu_numeric15 household_highest_edu_numeric16 household_highest_edu_numeric17 household_highest_edu_numeric18 household_highest_edu_numeric19 household_highest_edu_numeric20 household_highest_edu_numeric21 household_highest_edu_numeric22 tabulate household_highest_edu_numeric05 if household_size05 >= 1, missing tabulate household_highest_edu_numeric06 if household_size06 >= 1, missing tabulate household_highest_edu_numeric07 if household_size07 >= 1, missing tabulate household_highest_edu_numeric08 if household_size08 >= 1, missing tabulate household_highest_edu_numeric09 if household_size09 >= 1, missing tabulate household_highest_edu_numeric10 if household_size10 >= 1, missing tabulate household_highest_edu_numeric11 if household_size11 >= 1, missing tabulate household_highest_edu_numeric12 if household_size12 >= 1, missing tabulate household_highest_edu_numeric13 if household_size13 >= 1, missing tabulate household_highest_edu_numeric14 if household_size14 >= 1, missing tabulate household_highest_edu_numeric15 if household_size15 >= 1, missing tabulate household_highest_edu_numeric16 if household_size16 >= 1, missing tabulate household_highest_edu_numeric17 if household_size17 >= 1, missing tabulate household_highest_edu_numeric18 if household_size18 >= 1, missing tabulate household_highest_edu_numeric19 if household_size19 >= 1, missing tabulate household_highest_edu_numeric20 if household_size20 >= 1, missing tabulate household_highest_edu_numeric21 if household_size21 >= 1, missing tabulate household_highest_edu_numeric22 if household_size22 >= 1, missing sankey household_highest_edu_numeric05 household_highest_edu_numeric22 summarize household_size05 household_size06 household_size07 household_size08 household_size09 household_size10 household_size11 household_size12 household_size13 household_size14 household_size15 household_size16 household_size17 household_size18 household_size19 household_size20 household_size21 household_size22 tabulate household_size05 if household_size05 >= 1, missing tabulate household_size06 if household_size06 >= 1, missing tabulate household_size07 if household_size07 >= 1, missing tabulate household_size08 if household_size08 >= 1, missing tabulate household_size09 if household_size09 >= 1, missing tabulate household_size10 if household_size10 >= 1, missing tabulate household_size11 if household_size11 >= 1, missing tabulate household_size12 if household_size12 >= 1, missing tabulate household_size13 if household_size13 >= 1, missing tabulate household_size14 if household_size14 >= 1, missing tabulate household_size15 if household_size15 >= 1, missing tabulate household_size16 if household_size16 >= 1, missing tabulate household_size17 if household_size17 >= 1, missing tabulate household_size18 if household_size18 >= 1, missing tabulate household_size19 if household_size19 >= 1, missing tabulate household_size20 if household_size20 >= 1, missing tabulate household_size21 if household_size21 >= 1, missing tabulate household_size22 if household_size22 >= 1, missing summarize household_residence_work05 household_residence_work06 household_residence_work07 household_residence_work08 household_residence_work09 household_residence_work10 household_residence_work11 household_residence_work12 household_residence_work13 household_residence_work14 household_residence_work15 household_residence_work16 household_residence_work17 household_residence_work18 household_residence_work19 household_residence_work20 household_residence_work21 household_residence_work22 tabulate household_residence_work05 if household_size05 >= 1, missing tabulate household_residence_work06 if household_size06 >= 1, missing tabulate household_residence_work07 if household_size07 >= 1, missing tabulate household_residence_work08 if household_size08 >= 1, missing tabulate household_residence_work09 if household_size09 >= 1, missing tabulate household_residence_work10 if household_size10 >= 1, missing tabulate household_residence_work11 if household_size11 >= 1, missing tabulate household_residence_work12 if household_size12 >= 1, missing tabulate household_residence_work13 if household_size13 >= 1, missing tabulate household_residence_work14 if household_size14 >= 1, missing tabulate household_residence_work15 if household_size15 >= 1, missing tabulate household_residence_work16 if household_size16 >= 1, missing tabulate household_residence_work17 if household_size17 >= 1, missing tabulate household_residence_work18 if household_size18 >= 1, missing tabulate household_residence_work19 if household_size19 >= 1, missing tabulate household_residence_work20 if household_size20 >= 1, missing tabulate household_residence_work21 if household_size21 >= 1, missing tabulate household_residence_work22 if household_size22 >= 1, missing piechart household_background05 piechart household_background10 piechart household_background15 piechart household_background20 piechart household_background22 tabulate household_background05 if household_size05 >= 1, missing tabulate household_background06 if household_size06 >= 1, missing tabulate household_background07 if household_size07 >= 1, missing tabulate household_background08 if household_size08 >= 1, missing tabulate household_background09 if household_size09 >= 1, missing tabulate household_background10 if household_size10 >= 1, missing tabulate household_background11 if household_size11 >= 1, missing tabulate household_background12 if household_size12 >= 1, missing tabulate household_background13 if household_size13 >= 1, missing tabulate household_background14 if household_size14 >= 1, missing tabulate household_background15 if household_size15 >= 1, missing tabulate household_background16 if household_size16 >= 1, missing tabulate household_background17 if household_size17 >= 1, missing tabulate household_background18 if household_size18 >= 1, missing tabulate household_background19 if household_size19 >= 1, missing tabulate household_background20 if household_size20 >= 1, missing tabulate household_background21 if household_size21 >= 1, missing tabulate household_background22 if household_size22 >= 1, missing sankey household_background05 household_background20 sankey household_background05 household_background22 tabulate household_type_by_children05 if household_size05 >= 1, missing tabulate household_type_by_children06 if household_size06 >= 1, missing tabulate household_type_by_children07 if household_size07 >= 1, missing tabulate household_type_by_children08 if household_size08 >= 1, missing tabulate household_type_by_children09 if household_size09 >= 1, missing tabulate household_type_by_children10 if household_size10 >= 1, missing tabulate household_type_by_children11 if household_size11 >= 1, missing tabulate household_type_by_children12 if household_size12 >= 1, missing tabulate household_type_by_children13 if household_size13 >= 1, missing tabulate household_type_by_children14 if household_size14 >= 1, missing tabulate household_type_by_children15 if household_size15 >= 1, missing tabulate household_type_by_children16 if household_size16 >= 1, missing tabulate household_type_by_children17 if household_size17 >= 1, missing tabulate household_type_by_children18 if household_size18 >= 1, missing tabulate household_type_by_children19 if household_size19 >= 1, missing tabulate household_type_by_children20 if household_size20 >= 1, missing tabulate household_type_by_children21 if household_size21 >= 1, missing tabulate household_type_by_children22 if household_size22 >= 1, missing sankey household_type_by_children05 household_type_by_children10 sankey household_type_by_children10 household_type_by_children15 sankey household_type_by_children15 household_type_by_children20 sankey household_type_by_children20 household_type_by_children22 sankey household_type_by_children05 household_type_by_children22 piechart live_in_urban05 piechart live_in_urban11 piechart live_in_urban15 piechart live_in_urban20 piechart live_in_urban22 tabulate live_in_urban05 if household_size05 >= 1, missing tabulate live_in_urban06 if household_size06 >= 1, missing tabulate live_in_urban07 if household_size07 >= 1, missing tabulate live_in_urban08 if household_size08 >= 1, missing tabulate live_in_urban09 if household_size09 >= 1, missing //tabulate live_in_urban10 if household_size10 >= 1, missing tabulate live_in_urban11 if household_size11 >= 1, missing tabulate live_in_urban12 if household_size12 >= 1, missing tabulate live_in_urban13 if household_size13 >= 1, missing tabulate live_in_urban14 if household_size14 >= 1, missing tabulate live_in_urban15 if household_size15 >= 1, missing tabulate live_in_urban16 if household_size16 >= 1, missing tabulate live_in_urban17 if household_size17 >= 1, missing tabulate live_in_urban18 if household_size18 >= 1, missing tabulate live_in_urban19 if household_size19 >= 1, missing tabulate live_in_urban20 if household_size20 >= 1, missing tabulate live_in_urban21 if household_size21 >= 1, missing tabulate live_in_urban22 if household_size22 >= 1, missing sankey live_in_urban05 live_in_urban22 summarize owned_vehicle_all_per_household05 owned_vehicle_all_per_household06 owned_vehicle_all_per_household07 owned_vehicle_all_per_household08 owned_vehicle_all_per_household09 owned_vehicle_all_per_household10 owned_vehicle_all_per_household11 owned_vehicle_all_per_household12 owned_vehicle_all_per_household13 owned_vehicle_all_per_household14 owned_vehicle_all_per_household15 owned_vehicle_all_per_household16 owned_vehicle_all_per_household17 owned_vehicle_all_per_household18 owned_vehicle_all_per_household19 owned_vehicle_all_per_household20 owned_vehicle_all_per_household21 owned_vehicle_all_per_household22 summarize owned_vehicle_gray_per_household05 owned_vehicle_gray_per_household06 owned_vehicle_gray_per_household07 owned_vehicle_gray_per_household08 owned_vehicle_gray_per_household09 owned_vehicle_gray_per_household10 owned_vehicle_gray_per_household11 owned_vehicle_gray_per_household12 owned_vehicle_gray_per_household13 owned_vehicle_gray_per_household14 owned_vehicle_gray_per_household15 owned_vehicle_gray_per_household16 owned_vehicle_gray_per_household17 owned_vehicle_gray_per_household18 owned_vehicle_gray_per_household19 owned_vehicle_gray_per_household20 owned_vehicle_gray_per_household21 owned_vehicle_gray_per_household22 sankey owned_vehicle_gray_per_household05 owned_vehicle_gray_per_household20 sankey owned_vehicle_gray_per_household05 owned_vehicle_gray_per_household22 summarize owned_vehicle_green_per_household05 owned_vehicle_green_per_household06 owned_vehicle_green_per_household07 owned_vehicle_green_per_household08 owned_vehicle_green_per_household09 owned_vehicle_green_per_household10 owned_vehicle_green_per_household11 owned_vehicle_green_per_household12 owned_vehicle_green_per_household13 owned_vehicle_green_per_household14 owned_vehicle_green_per_household15 owned_vehicle_green_per_household16 owned_vehicle_green_per_household17 owned_vehicle_green_per_household18 owned_vehicle_green_per_household19 owned_vehicle_green_per_household20 owned_vehicle_green_per_household21 owned_vehicle_green_per_household22 sankey owned_vehicle_green_per_household05 owned_vehicle_green_per_household10 sankey owned_vehicle_green_per_household10 owned_vehicle_green_per_household15 sankey owned_vehicle_green_per_household15 owned_vehicle_green_per_household20 sankey owned_vehicle_green_per_household20 owned_vehicle_green_per_household22 sankey owned_vehicle_green_per_household05 owned_vehicle_green_per_household22 // To find the number of households with zero green vehicle in this sub-poulation summarize household_size05 if owned_vehicle_green_per_household05 == 0 summarize household_size06 if owned_vehicle_green_per_household06 == 0 summarize household_size07 if owned_vehicle_green_per_household07 == 0 summarize household_size08 if owned_vehicle_green_per_household08 == 0 summarize household_size09 if owned_vehicle_green_per_household09 == 0 summarize household_size10 if owned_vehicle_green_per_household10 == 0 summarize household_size11 if owned_vehicle_green_per_household11 == 0 summarize household_size12 if owned_vehicle_green_per_household12 == 0 summarize household_size13 if owned_vehicle_green_per_household13 == 0 summarize household_size14 if owned_vehicle_green_per_household14 == 0 summarize household_size15 if owned_vehicle_green_per_household15 == 0 summarize household_size16 if owned_vehicle_green_per_household16 == 0 summarize household_size17 if owned_vehicle_green_per_household17 == 0 summarize household_size18 if owned_vehicle_green_per_household18 == 0 summarize household_size19 if owned_vehicle_green_per_household19 == 0 summarize household_size20 if owned_vehicle_green_per_household20 == 0 summarize household_size21 if owned_vehicle_green_per_household21 == 0 summarize household_size22 if owned_vehicle_green_per_household22 == 0 // To find the number of households with at least one green vehicle in this sub-poulation summarize household_size05 if owned_vehicle_green_per_household05 >= 1 summarize household_size06 if owned_vehicle_green_per_household06 >= 1 summarize household_size07 if owned_vehicle_green_per_household07 >= 1 summarize household_size08 if owned_vehicle_green_per_household08 >= 1 summarize household_size09 if owned_vehicle_green_per_household09 >= 1 summarize household_size10 if owned_vehicle_green_per_household10 >= 1 summarize household_size11 if owned_vehicle_green_per_household11 >= 1 summarize household_size12 if owned_vehicle_green_per_household12 >= 1 summarize household_size13 if owned_vehicle_green_per_household13 >= 1 summarize household_size14 if owned_vehicle_green_per_household14 >= 1 summarize household_size15 if owned_vehicle_green_per_household15 >= 1 summarize household_size16 if owned_vehicle_green_per_household16 >= 1 summarize household_size17 if owned_vehicle_green_per_household17 >= 1 summarize household_size18 if owned_vehicle_green_per_household18 >= 1 summarize household_size19 if owned_vehicle_green_per_household19 >= 1 summarize household_size20 if owned_vehicle_green_per_household20 >= 1 summarize household_size21 if owned_vehicle_green_per_household21 >= 1 summarize household_size22 if owned_vehicle_green_per_household22 >= 1 textblock Descriptive analysis for the paper: Gray Adopters --------------------------------------- 2005 to 2022: An overview endblock use household_DS_2005_2022_always_gray_owners_descriptive summarize household_income05 household_income06 household_income07 household_income08 household_income09 household_income10 household_income11 household_income12 household_income13 household_income14 household_income15 household_income16 household_income17 household_income18 household_income19 household_income20 household_income21 summarize household_wealth05 household_wealth06 household_wealth07 household_wealth08 household_wealth09 household_wealth10 household_wealth11 household_wealth12 household_wealth13 household_wealth14 household_wealth15 household_wealth16 household_wealth17 household_wealth18 household_wealth19 household_wealth20 summarize household_debt05 household_debt06 household_debt07 household_debt08 household_debt09 household_debt10 household_debt11 household_debt12 household_debt13 household_debt14 household_debt15 household_debt16 household_debt17 household_debt18 household_debt19 household_debt20 household_debt21 summarize household_highest_edu_numeric05 household_highest_edu_numeric06 household_highest_edu_numeric07 household_highest_edu_numeric08 household_highest_edu_numeric09 household_highest_edu_numeric10 household_highest_edu_numeric11 household_highest_edu_numeric12 household_highest_edu_numeric13 household_highest_edu_numeric14 household_highest_edu_numeric15 household_highest_edu_numeric16 household_highest_edu_numeric17 household_highest_edu_numeric18 household_highest_edu_numeric19 household_highest_edu_numeric20 household_highest_edu_numeric21 household_highest_edu_numeric22 tabulate household_highest_edu_numeric05 if household_size05 >= 1, missing tabulate household_highest_edu_numeric06 if household_size06 >= 1, missing tabulate household_highest_edu_numeric07 if household_size07 >= 1, missing tabulate household_highest_edu_numeric08 if household_size08 >= 1, missing tabulate household_highest_edu_numeric09 if household_size09 >= 1, missing tabulate household_highest_edu_numeric10 if household_size10 >= 1, missing tabulate household_highest_edu_numeric11 if household_size11 >= 1, missing tabulate household_highest_edu_numeric12 if household_size12 >= 1, missing tabulate household_highest_edu_numeric13 if household_size13 >= 1, missing tabulate household_highest_edu_numeric14 if household_size14 >= 1, missing tabulate household_highest_edu_numeric15 if household_size15 >= 1, missing tabulate household_highest_edu_numeric16 if household_size16 >= 1, missing tabulate household_highest_edu_numeric17 if household_size17 >= 1, missing tabulate household_highest_edu_numeric18 if household_size18 >= 1, missing tabulate household_highest_edu_numeric19 if household_size19 >= 1, missing tabulate household_highest_edu_numeric20 if household_size20 >= 1, missing tabulate household_highest_edu_numeric21 if household_size21 >= 1, missing tabulate household_highest_edu_numeric22 if household_size22 >= 1, missing sankey household_highest_edu_numeric05 household_highest_edu_numeric22 summarize household_size05 household_size06 household_size07 household_size08 household_size09 household_size10 household_size11 household_size12 household_size13 household_size14 household_size15 household_size16 household_size17 household_size18 household_size19 household_size20 household_size21 household_size22 tabulate household_size05 if household_size05 >= 1, missing tabulate household_size06 if household_size06 >= 1, missing tabulate household_size07 if household_size07 >= 1, missing tabulate household_size08 if household_size08 >= 1, missing tabulate household_size09 if household_size09 >= 1, missing tabulate household_size10 if household_size10 >= 1, missing tabulate household_size11 if household_size11 >= 1, missing tabulate household_size12 if household_size12 >= 1, missing tabulate household_size13 if household_size13 >= 1, missing tabulate household_size14 if household_size14 >= 1, missing tabulate household_size15 if household_size15 >= 1, missing tabulate household_size16 if household_size16 >= 1, missing tabulate household_size17 if household_size17 >= 1, missing tabulate household_size18 if household_size18 >= 1, missing tabulate household_size19 if household_size19 >= 1, missing tabulate household_size20 if household_size20 >= 1, missing tabulate household_size21 if household_size21 >= 1, missing tabulate household_size22 if household_size22 >= 1, missing summarize household_residence_work05 household_residence_work06 household_residence_work07 household_residence_work08 household_residence_work09 household_residence_work10 household_residence_work11 household_residence_work12 household_residence_work13 household_residence_work14 household_residence_work15 household_residence_work16 household_residence_work17 household_residence_work18 household_residence_work19 household_residence_work20 household_residence_work21 household_residence_work22 tabulate household_residence_work05 if household_size05 >= 1, missing tabulate household_residence_work06 if household_size06 >= 1, missing tabulate household_residence_work07 if household_size07 >= 1, missing tabulate household_residence_work08 if household_size08 >= 1, missing tabulate household_residence_work09 if household_size09 >= 1, missing tabulate household_residence_work10 if household_size10 >= 1, missing tabulate household_residence_work11 if household_size11 >= 1, missing tabulate household_residence_work12 if household_size12 >= 1, missing tabulate household_residence_work13 if household_size13 >= 1, missing tabulate household_residence_work14 if household_size14 >= 1, missing tabulate household_residence_work15 if household_size15 >= 1, missing tabulate household_residence_work16 if household_size16 >= 1, missing tabulate household_residence_work17 if household_size17 >= 1, missing tabulate household_residence_work18 if household_size18 >= 1, missing tabulate household_residence_work19 if household_size19 >= 1, missing tabulate household_residence_work20 if household_size20 >= 1, missing tabulate household_residence_work21 if household_size21 >= 1, missing tabulate household_residence_work22 if household_size22 >= 1, missing piechart household_background05 piechart household_background10 piechart household_background15 piechart household_background20 piechart household_background22 tabulate household_background05 if household_size05 >= 1, missing tabulate household_background06 if household_size06 >= 1, missing tabulate household_background07 if household_size07 >= 1, missing tabulate household_background08 if household_size08 >= 1, missing tabulate household_background09 if household_size09 >= 1, missing tabulate household_background10 if household_size10 >= 1, missing tabulate household_background11 if household_size11 >= 1, missing tabulate household_background12 if household_size12 >= 1, missing tabulate household_background13 if household_size13 >= 1, missing tabulate household_background14 if household_size14 >= 1, missing tabulate household_background15 if household_size15 >= 1, missing tabulate household_background16 if household_size16 >= 1, missing tabulate household_background17 if household_size17 >= 1, missing tabulate household_background18 if household_size18 >= 1, missing tabulate household_background19 if household_size19 >= 1, missing tabulate household_background20 if household_size20 >= 1, missing tabulate household_background21 if household_size21 >= 1, missing tabulate household_background22 if household_size22 >= 1, missing sankey household_background05 household_background20 sankey household_background05 household_background22 tabulate household_type_by_children05 if household_size05 >= 1, missing tabulate household_type_by_children06 if household_size06 >= 1, missing tabulate household_type_by_children07 if household_size07 >= 1, missing tabulate household_type_by_children08 if household_size08 >= 1, missing tabulate household_type_by_children09 if household_size09 >= 1, missing tabulate household_type_by_children10 if household_size10 >= 1, missing tabulate household_type_by_children11 if household_size11 >= 1, missing tabulate household_type_by_children12 if household_size12 >= 1, missing tabulate household_type_by_children13 if household_size13 >= 1, missing tabulate household_type_by_children14 if household_size14 >= 1, missing tabulate household_type_by_children15 if household_size15 >= 1, missing tabulate household_type_by_children16 if household_size16 >= 1, missing tabulate household_type_by_children17 if household_size17 >= 1, missing tabulate household_type_by_children18 if household_size18 >= 1, missing tabulate household_type_by_children19 if household_size19 >= 1, missing tabulate household_type_by_children20 if household_size20 >= 1, missing tabulate household_type_by_children21 if household_size21 >= 1, missing tabulate household_type_by_children22 if household_size22 >= 1, missing sankey household_type_by_children05 household_type_by_children10 sankey household_type_by_children10 household_type_by_children15 sankey household_type_by_children15 household_type_by_children20 sankey household_type_by_children20 household_type_by_children22 sankey household_type_by_children05 household_type_by_children22 piechart live_in_urban05 piechart live_in_urban11 piechart live_in_urban15 piechart live_in_urban20 piechart live_in_urban22 tabulate live_in_urban05 if household_size05 >= 1, missing tabulate live_in_urban06 if household_size06 >= 1, missing tabulate live_in_urban07 if household_size07 >= 1, missing tabulate live_in_urban08 if household_size08 >= 1, missing tabulate live_in_urban09 if household_size09 >= 1, missing //tabulate live_in_urban10 if household_size10 >= 1, missing tabulate live_in_urban11 if household_size11 >= 1, missing tabulate live_in_urban12 if household_size12 >= 1, missing tabulate live_in_urban13 if household_size13 >= 1, missing tabulate live_in_urban14 if household_size14 >= 1, missing tabulate live_in_urban15 if household_size15 >= 1, missing tabulate live_in_urban16 if household_size16 >= 1, missing tabulate live_in_urban17 if household_size17 >= 1, missing tabulate live_in_urban18 if household_size18 >= 1, missing tabulate live_in_urban19 if household_size19 >= 1, missing tabulate live_in_urban20 if household_size20 >= 1, missing tabulate live_in_urban21 if household_size21 >= 1, missing tabulate live_in_urban22 if household_size22 >= 1, missing sankey live_in_urban05 live_in_urban22 summarize owned_vehicle_all_per_household05 owned_vehicle_all_per_household06 owned_vehicle_all_per_household07 owned_vehicle_all_per_household08 owned_vehicle_all_per_household09 owned_vehicle_all_per_household10 owned_vehicle_all_per_household11 owned_vehicle_all_per_household12 owned_vehicle_all_per_household13 owned_vehicle_all_per_household14 owned_vehicle_all_per_household15 owned_vehicle_all_per_household16 owned_vehicle_all_per_household17 owned_vehicle_all_per_household18 owned_vehicle_all_per_household19 owned_vehicle_all_per_household20 owned_vehicle_all_per_household21 owned_vehicle_all_per_household22 summarize owned_vehicle_gray_per_household05 owned_vehicle_gray_per_household06 owned_vehicle_gray_per_household07 owned_vehicle_gray_per_household08 owned_vehicle_gray_per_household09 owned_vehicle_gray_per_household10 owned_vehicle_gray_per_household11 owned_vehicle_gray_per_household12 owned_vehicle_gray_per_household13 owned_vehicle_gray_per_household14 owned_vehicle_gray_per_household15 owned_vehicle_gray_per_household16 owned_vehicle_gray_per_household17 owned_vehicle_gray_per_household18 owned_vehicle_gray_per_household19 owned_vehicle_gray_per_household20 owned_vehicle_gray_per_household21 owned_vehicle_gray_per_household22 // Note that we know this group has never had a green car... summarize owned_vehicle_green_per_household05 owned_vehicle_green_per_household06 owned_vehicle_green_per_household07 owned_vehicle_green_per_household08 owned_vehicle_green_per_household09 owned_vehicle_green_per_household10 owned_vehicle_green_per_household11 owned_vehicle_green_per_household12 owned_vehicle_green_per_household13 owned_vehicle_green_per_household14 owned_vehicle_green_per_household15 owned_vehicle_green_per_household16 owned_vehicle_green_per_household17 owned_vehicle_green_per_household18 owned_vehicle_green_per_household19 owned_vehicle_green_per_household20 owned_vehicle_green_per_household21 owned_vehicle_green_per_household22 sankey owned_vehicle_gray_per_household05 owned_vehicle_gray_per_household22 // To find the number of households with zero gray vehicle in this sub-poulation summarize household_size05 if owned_vehicle_gray_per_household05 == 0 summarize household_size06 if owned_vehicle_gray_per_household06 == 0 summarize household_size07 if owned_vehicle_gray_per_household07 == 0 summarize household_size08 if owned_vehicle_gray_per_household08 == 0 summarize household_size09 if owned_vehicle_gray_per_household09 == 0 summarize household_size10 if owned_vehicle_gray_per_household10 == 0 summarize household_size11 if owned_vehicle_gray_per_household11 == 0 summarize household_size12 if owned_vehicle_gray_per_household12 == 0 summarize household_size13 if owned_vehicle_gray_per_household13 == 0 summarize household_size14 if owned_vehicle_gray_per_household14 == 0 summarize household_size15 if owned_vehicle_gray_per_household15 == 0 summarize household_size16 if owned_vehicle_gray_per_household16 == 0 summarize household_size17 if owned_vehicle_gray_per_household17 == 0 summarize household_size18 if owned_vehicle_gray_per_household18 == 0 summarize household_size19 if owned_vehicle_gray_per_household19 == 0 summarize household_size20 if owned_vehicle_gray_per_household20 == 0 summarize household_size21 if owned_vehicle_gray_per_household21 == 0 summarize household_size22 if owned_vehicle_gray_per_household22 == 0 // To find the number of households with at least one gray vehicle in this sub-poulation: We know that the households of this population do not own any green vehicles summarize household_size05 if owned_vehicle_gray_per_household05 >= 1 summarize household_size06 if owned_vehicle_gray_per_household06 >= 1 summarize household_size07 if owned_vehicle_gray_per_household07 >= 1 summarize household_size08 if owned_vehicle_gray_per_household08 >= 1 summarize household_size09 if owned_vehicle_gray_per_household09 >= 1 summarize household_size10 if owned_vehicle_gray_per_household10 >= 1 summarize household_size11 if owned_vehicle_gray_per_household11 >= 1 summarize household_size12 if owned_vehicle_gray_per_household12 >= 1 summarize household_size13 if owned_vehicle_gray_per_household13 >= 1 summarize household_size14 if owned_vehicle_gray_per_household14 >= 1 summarize household_size15 if owned_vehicle_gray_per_household15 >= 1 summarize household_size16 if owned_vehicle_gray_per_household16 >= 1 summarize household_size17 if owned_vehicle_gray_per_household17 >= 1 summarize household_size18 if owned_vehicle_gray_per_household18 >= 1 summarize household_size19 if owned_vehicle_gray_per_household19 >= 1 summarize household_size20 if owned_vehicle_gray_per_household20 >= 1 summarize household_size21 if owned_vehicle_gray_per_household21 >= 1 summarize household_size22 if owned_vehicle_gray_per_household22 >= 1