Extract parts from numerical values

The int() function can be used to extract parts from numerical values. It rounds downwards to nearest integer number. Alternatively the floor() function may be used.

This example demonstrates how to generate age per 2020 from the variable birthdate with the numerical value format YYYYMM.

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

create-dataset demography
import db/BEFOLKNING_FOEDSELS_AAR_MND as birthdate

//Calculate age in 2020 from birthdate 
generate age = 2020 - int(birthdate / 100)