How to define and create populations

In microdata.no the left-join-principle is being used. This means that the first variable imported into your dataset defines the maximum size of the population. If this is a universal variable such as gender, you will ensure that the dataset consists of as many as possible from the total Norwegian population, including persons who are eighter dead, emigrated or not born at the specific time measurement(s) you wish to base your analysis on.

If you start by importing a variable that only measure a limited number of individuals, f.x. data on work disable benefits, your data will only consist of people in Norway that received such benefits at the particular time of measurement.

It is not possible to make the population bigger than what variable number 1 allows. Therefore it is important to evaluate which variable is to imported first, in order to include all the relevant individuals/units in your analysis. It is possible to make your population smaller in later stages by using the commandos drop if or keep if.

//Connect to databank
require no.ssb.fdb:1 as fdb1

//Example 1: Population = all residents in municipality of Bergen per 1/6 2015
create-dataset eks1
import fdb1/BOSATTEFDT_BOSTED 2015-06-01 as municipality
keep if municipality == '1201'

//Example 2: Population = all residents in county of Hordaland per 1/6 2015
create-dataset eks2
import fdb1/BOSATTEFDT_BOSTED 2015-06-01 as municipality
keep if substr( municipality,1,2) == '12'

//Example 3: Population = people with a yearly work related income in 2015 
create-dataset eks3
import fdb1/INNTEKT_WYRKINNT 2015-06-01 as income

//Example 4: When starting with a universal variable but only want to 
//analyse individuals with specific characteristics at a given time
create-dataset eks4
import fdb1/BEFOLKNING_KJOENN as sex
import fdb1/INNTEKT_WYRKINNT 2015-06-01 as income
drop if sysmiss( income )

//Example 5: When starting with a universal variable but only want to 
//analyse individuals that where residents in Norway at a given time
//The variable BEFOLKNING_REGSTAT is suited for this purpose as it contains
//code values for "resident","dead" and "emigrated". 
//"Resident" is represented by the code value '1'.
create-dataset eks5
import fdb1/BEFOLKNING_KJOENN as sex
import fdb1/BEFOLKNING_REGSTAT 2015-06-01 as registerstatus
keep if registerstatus == '1'