Skip to main content

How to use parental information in analysis

The database contains variables for father’s and mother’s birth identification number respectively, which makes it possible to link parental information with an individual based dataset.

The command merge makes it possible to link datasets. The key unit identification variable of the target dataset is used by default, unless customised through an on option.

In this example, a separate dataset is made for fathers and mothers, which are linked to a personal level dataset via the key-link variables idnr_father and idnr_mother.

 //Connect to datastore
require no.ssb.fdb:23 as db

//Create a main dataset with links to fathers and mothers
create-dataset persondata
import db/INNTEKT_WYRKINNT 2021-01-01 as workincome
import db/BEFOLKNING_KJOENN as gender
import db/NUDB_BU 2021-01-01 as edu
import db/BEFOLKNING_FAR_FNR as idnr_father
import db/BEFOLKNING_MOR_FNR as idnr_mother

//Import data on parents and merge into main dataset
create-dataset parents
import db/INNTEKT_WYRKINNT 2021-01-01 as workincome_father
import db/NUDB_BU 2021-01-01 as edu_father
clone-variables workincome_father -> workincome_mother
clone-variables edu_father -> edu_mother
merge workincome_father edu_father into persondata on idnr_father
merge workincome_mother edu_mother into persondata on idnr_mother

//Perform basic linear regression analysis to test for covariation with parental income
use persondata
generate male = 0
replace male = 1 if gender == '1'

destring edu
generate high_edu = 0
replace high_edu = 1 if edu >= 700000 & edu < 900000
replace high_edu = edu if sysmiss(edu)

destring edu_father
generate high_edu_father = 0
replace high_edu_father = 1 if edu_father >= 700000 & edu_father < 900000
replace high_edu_father = edu_father if sysmiss(edu_father)

destring edu_mother
generate high_edu_mother = 0
replace high_edu_mother = 1 if edu_mother >= 700000 & edu_mother < 900000
replace high_edu_mother = edu_mother if sysmiss(edu_mother)

summarize workincome workincome_father workincome_mother
histogram workincome_father, percent
histogram workincome_mother, percent
correlate workincome_father workincome_mother
tabulate high_edu_father high_edu_mother

regress workincome male workincome_father workincome_mother high_edu high_edu_father high_edu_mother