Descriptive statistics: sankey

The sankey command can be used on categorical variables to create transition diagrams for displaying movements between unit-level values. The most common is to create diagrams that show status changes measured over time, e.g. place of residence in 2016 vs. place of residence in 2021. Movements between statuses are represented by arrows that are wider the more units are in the transition in question.

It is also possible to look at transitions between different types of states, e.g. jobseeker status in 2016 vs. employment status in 2021.

// Transitions diagrams (Sankey)

require no.ssb.fdb:23 as db

create-dataset demographics
import db/SIVSTANDFDT_SIVSTAND 2016-01-01 as maritalstate16
import db/SIVSTANDFDT_SIVSTAND 2021-01-01 as maritalstate21
import db/BOSATTEFDT_BOSTED 2016-01-01 as residence16
import db/BOSATTEFDT_BOSTED 2021-01-01 as residence21

// Recoding from municipality to county level 
generate county16 = substr(residence16,1,2)
generate county21 = substr(residence21,1,2)

define-labels countystring '01' 'Østfold' '02' 'Akershus' '03' 'Oslo' '04' 'Hedmark' '05' 'Oppland' '06' 'Buskerud' '07' 'Vestfold' '08' 'Telemark' '09' 'Aust-Agder' '10' 'Vest-Agder' '11' 'Rogaland' '12' 'Hordaland' '14' 'Sogn and Fjordane' '15' 'Møre and Romsdal' '16' 'Sør-Trøndelag' '17' 'Nord-Trøndelag' '18' 'Nordland' '19' 'Troms' '20' 'Finnmark' '99' 'Unknown'

assign-labels county16 countystring
assign-labels county21 countystring

sankey county16 county21 if county16 == '12'
sankey county16 county21 if county21 == '03'
sankey county16 county21 if county21 == '03' & county16 != '03'

sankey maritalstate16 maritalstate21
sankey maritalstate16 maritalstate21 if maritalstate16 == '2'