Register-based research at Statistics Denmark
A guide in R, from research question to exported results
This guide is for researchers who do register-based studies on the Statistics Denmark (DST) research servers and do the data work themselves in R.
It assumes that your project already has access to DST and that your registers have been delivered. It does not cover how to apply for data, and it does not teach statistical methods: the analysis pages show which R tools fit a register study and point to courses and books for the theory.
One assumption runs through almost all the code: your project’s registers are stored as parquet files, and you read them by name with the R package fastreg, as in read_register("bef"). Set up register reading checks whether that holds for your project and says what to do if it does not.
Reading SAS files today? Three pages change your daily work: Your project folder and its file types, Set up register reading, and Read a register.
Already working on DST? Go to what you need
The menu is grouped by what you are trying to do:
- Registers and data: what the most used registers hold, and their columns (check them against your delivery), which register a variable is in and what a code means.
- Data by subject: one page per kind of data, such as hospital diagnoses, prescriptions, education and income, laboratory results, births and costs. The menu names both the subject and the register.
- Build your study: define the study population and index date, choose a comparison group, extract the variables your study needs and join them into one dataset with follow-up time.
- Analyse and export: choose a method, make tables and figures, fit models, and get the results out through DST’s output control. Read Output control and export before you build tables.
- While you code: look up a function, organise your scripts, or find a ready-made algorithm or package and courses and books.
- When something is wrong: the code stopped or gave nothing, or the code ran but the answer looks wrong.
Start here: set up and read a register
You do not need experience with registers. Do these seven steps in order:
- Plan your study
- R: the bare essentials (skip it if you know R)
- Log in to DST
- Your project folder and its file types
- Set up register reading (parquet and fastreg)
- Read a register: open, filter, select, collect, then inspect what you got back
- Check what your project received
Know DST, but new on a project? Do Set up register reading and Check what your project received again. No access to DST yet? The practice run on synthetic data does a complete extraction on your own computer.
Three ways to search
- The search box in the top bar finds exact words.
- Search by meaning finds a section by a synonym or by the Danish word.
- Find a variable searches every column in every register documented in the guide.
Want to help?
If you have reusable code for register work, for example weighted medication use or building episodes, drafts are welcome. Want to help? says what is most useful and how to send it.