Analyze shift schedules
The script below shows how to work with job data from the A scheme. This was reviewed in our theme course, which was run twice in 2022.
This concrete example demonstrates how to carry out an analysis of shift schedules.
require no.ssb.fdb:30 as db
// Create dataset for employed (person data)
create-dataset employed2
import db/ARBLONN_PERS_KJOENN 2021-07-16 as gender
import db/ARBLONN_PERS_ALDER 2021-07-16 as age
// Create dataset for employment relations (job data)
create-dataset employment_relations2
import db/ARBLONN_ARB_TID_ORDNING 2021-07-16 as work_arrangement
import db/ARBLONN_ARB_ARBEIDSTID 2021-07-16 as worktime
import db/ARBEIDSFORHOLD_PERSON as personid
tabulate work_arrangement
// Aggregate from job data to person data level by summing work time and job percentage per person. Then merge job information on the person dataset employed
keep if work_arrangement == 'dogn355'
generate num_shift_work = 1
collapse (sum) num_shift_work worktime, by(personid)
merge num_shift_work worktime into employed2
// Create shift work statistics
use employed2
tabulate num_shift_work, summarize(worktime) mean freq
generate shift_work = 0
replace shift_work = 1 if num_shift_work >= 1
summarize worktime if shift_work
tabulate shift_work, cellpct freq
tabulate gender shift_work, rowpct freq
tabulate gender if shift_work, summarize(worktime)
generate age_group = 1
replace age_group = 2 if age > 25
replace age_group = 3 if age > 40
replace age_group = 4 if age > 60
assign-labels age_group age_label
tabulate age_group shift_work, rowpct freq
tabulate age_group if shift_work, summarize(worktime)