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.

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

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

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

//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 BEFOLKNING_KJOENN as kjønn
import INNTEKT_WYRKINNT 2015-06-01 as yrkesinntekt
drop if sysmiss( yrkesinntekt )

//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 BEFOLKNING_KJOENN as kjønn
import BEFOLKNING_REGSTAT 2015-06-01 as registerstatus
keep if registerstatus == '1'