Below we demonstrate how to create variables that contain the result of various calculations on row level. Row functions perform calculations at the individual level, across selected variables.
This is just a small bunch of all available row functions. Use the
help-function command to get an overview of other functions.
require no.ssb.fdb:23 as db create-dataset rowtest import db/BEFOLKNING_KOMMNR_FAKTISK 2019-01-01 as municipality sample 10000 1234 import db/BEFOLKNING_KJOENN as gender import db/INNTEKT_WLONN 2019-01-01 as wage19 import db/INNTEKT_WLONN 2020-01-01 as wage20 import db/INNTEKT_WLONN 2021-01-01 as wage21 //Merge string values generate firstname = 'Ole' if gender == '1' replace firstname = 'Kari' if gender == '2' generate lastname = 'Hansen' generate name = rowconcat(firstname, ' ', lastname) tabulate name //Find the highest annual salary for each individual over the years 2019-2021 generate maxwage19_21 = rowmax(wage19, wage20, wage21) summarize maxwage19_21