Merge job data into individual level datasets
The example below demonstrates how to link data with Employment as the entity type with another dataset with Person as the entity type.
Data from the so-called “A scheme” with the prefix “ARBLONN_ARB_” has Employment as unit type (i.e. up to several records per person). To be able to link such data together with normal personal data sets, one must first use the command collapse
to sum up the information related to each individual employment relationship. The data set then has Person as the unit type (one record per person), and can thus be linked with the personal data set “employed”.
//Connect to database
require no.ssb.fdb:23 as db
//Create employees dataset (person data)
create-dataset employees
import db/ARBLONN_PERS_KJOENN 2021-07-16 as gender
import db/ARBLONN_PERS_ALDER 2021-07-16 as age
//Create employment dataset (job data)
create-dataset employment
import db/ARBLONN_ARB_ARBEIDSTID 2021-07-16 as work_hours
import db/ARBLONN_ARB_STILLINGSPST 2021-07-16 as empl_pct
import db/ARBEIDSFORHOLD_PERSON as personid
//Aggregate from job data to person data by adding up work hours and employment precentages per person. Then link job data into the person dataset employees
collapse (sum) work_hours empl_pct, by(personid)
merge work_hours empl_pct into employees
//Generate job statistics
use employees
summarize work_hours empl_pct
tabulate gender, summarize(work_hours)
tabulate gender, summarize(empl_pct)
generate agegr = 1
replace agegr = 2 if age > 25
replace agegr = 3 if age > 40
replace agegr = 4 if age > 60
define-labels agelabel 1 '0-25' 2 '26-40' 3 '41-60' 4 '61->'
assign-labels agegr agelabel
tabulate agegr
tabulate agegr gender, summarize(work_hours)
tabulate agegr gender, summarize(empl_pct)