# csdata

`csdata` provides structural data for Norway.

Please see https://niphr.github.io/csdata/reference/index.html for a quick overview of all available datasets and functions.

## Location

Valid locations (and location types) are available in `csdata::nor_locations_names()`. Uncommon/internal use is demarcated by a line through the text.

Valid locations and location types in the csverse format
Geo (Granularity) | N | Examples
--- | --- | ---
location_code1 | location_name2 | location_name_description_nb3 | location_name_file_nb_utf4 | location_name_file_nb_ascii5
nation | 1 | nation_nor | Norge-Noreg-Norway | Norge-Noreg-Norway | Norge_Noreg_Norway | norge_noreg_norway
georegion6 | 5 | georegion_nor1 | Nord-Norge-Davvi-Norggas | Nord-Norge-Davvi-Norggas (landsdel) | Nord_Norge_Davvi_Norggas_landsdel | nord_norge_davvi_norggas_landsdel
county | 15 | county_nor42 | Agder | Agder (fylke) | Agder_fylke | agder_fylke
notmainlandcounty | 2 | notmainlandcounty_nor22 | Utenfor fastlands-Norge (Jan Mayen) | Utenfor fastlands-Norge (Jan Mayen) (fylke) | Utenfor_fastlands_Norge_Jan_Mayen_fylke | utenfor_fastlands_norge_jan_mayen_fylke
missingcounty | 1 | missingcounty_nor99 | Ukjent fylke | Ukjent fylke (fylke) | Ukjent_fylke | ukjent_fylke
municip | 357 | municip_nor1820 | Alstahaug | Alstahaug (kommune i Nordland-Nordlándda) | Alstahaug_kommune_i_Nordland_Nordlándda | alstahaug_kommune_i_nordland_nordlandda
notmainlandmunicip | 2 | notmainlandmunicip_nor2200 | Jan Mayen | Jan Mayen (kommune i Utenfor fastlands-Norge (Jan Mayen)) | Jan_Mayen_kommune_i_Utenfor_fastlands_Norge_Jan_Mayen | jan_mayen_kommune_i_utenfor_fastlands_norge_jan_mayen
missingmunicip | 1 | missingmunicip_nor9999 | Ukjent kommune | Ukjent kommune (kommune i Ukjent fylke) | Ukjent_kommune_i_Ukjent_fylke | ukjent_kommune_i_ukjent_fylke
wardoslo | 15 | wardoslo_nor030112 | Alna | Alna (bydel i Oslo-Oslove) | Alna_bydel_i_Oslo_Oslove | alna_bydel_i_oslo_oslove
wardbergen | 8 | wardbergen_nor460101 | Arna | Arna (bydel i Bergen) | Arna_bydel_i_Bergen | arna_bydel_i_bergen
wardstavanger | 9 | wardstavanger_nor110303 | Eiganes og Våland | Eiganes og Våland (bydel i Stavanger) | Eiganes_og_Våland_bydel_i_Stavanger | eiganes_og_valand_bydel_i_stavanger
wardtrondheim | 4 | wardtrondheim_nor500104 | Heimdal | Heimdal (bydel i Trondheim) | Heimdal_bydel_i_Trondheim | heimdal_bydel_i_trondheim
extrawardoslo | 2 | extrawardoslo_nor030117 | Marka | Marka (bydel i Oslo-Oslove) | Marka_bydel_i_Oslo_Oslove | marka_bydel_i_oslo_oslove
missingwardbergen | 1 | missingwardbergen_nor460199 | Ukjent bydel i Bergen | Ukjent bydel i Bergen (bydel i Bergen) | Ukjent_bydel_i_Bergen | ukjent_bydel_i_bergen
missingwardoslo | 1 | missingwardoslo_nor030199 | Ukjent bydel i Oslo | Ukjent bydel i Oslo (bydel i Oslo-Oslove) | Ukjent_bydel_i_Oslo_Oslove | ukjent_bydel_i_oslo_oslove
missingwardstavanger | 1 | missingwardstavanger_nor110399 | Ukjent bydel i Stavanger | Ukjent bydel i Stavanger (bydel i Stavanger) | Ukjent_bydel_i_Stavanger | ukjent_bydel_i_stavanger
missingwardtrondheim | 1 | missingwardtrondheim_nor500199 | Ukjent bydel i Trondheim | Ukjent bydel i Trondheim (bydel i Trondheim) | Ukjent_bydel_i_Trondheim | ukjent_bydel_i_trondheim
baregion7 | 159 | baregion_nor111 | Alstahaug | Alstahaug (BA-region) | Alstahaug_BA_region | alstahaug_ba_region
mtregion8 | 5 | mtregion_nor4 | Midt-Norge | Midt-Norge (Mattilsynet-region) | Midt_Norge_Mattilsynet_region | midt_norge_mattilsynet_region
lab | 26 | lab_nor000030 | Akershus Universitetssykehus | Akershus Universitetssykehus (lab) | Akershus_Universitetssykehus_lab | akershus_universitetssykehus_lab
1 location_code: Used a) inside datasets and b) in data file names for transfer of data/results between analytic systems. All values are unique.
2 location_name: Used (rarely) inside results (figures, tables, documents). Can be confusing as some names are duplicated. Its rare usage is demarcated by a line through the text.
3 location_name_description_nb: Used (frequently) inside results (figures, tables, documents). All values are unique.
4 location_name_file_nb_utf: Used (frequently) in the file names for results (figures, tables, documents). All values are unique.
5 location_name_file_nb_ascii: Used (rarely) in the file names for results (figures, tables, documents). Used if file systems have problems with the Norwegian letters æøå. All values are unique.
6 Landsdeler/riskdeler. Geographical regions.
7 Bo- og arbeidsmarkedsregioner. Housing and labor market regions.
8 Mattilsynet-regioner. Food authority regions.

## Ages

Ages should be coded as characters and should always contain 3 digits. If it is an age range, the two ages are joined by an underscore (e.g. `005_010`).

Use `085p` instead of `>=085` or `85+`, as this will allow for an easy conversion from long to wide formatted data.

Valid ages in the csverse format
Value | class | Definition
--- | --- | ---
"000" | character | One year age group (0 year olds)
"079" | character | One year age group(79 year olds)
"000_004" | character | Age span of 0-4 year olds
"065p" | character | Age span of >=65 year olds
"missing" | character | Missing/unknown
"total" | character | Everyone

This format will help your data be easily sorted, kept in the right order, and generate valid variable names if converted to wide-format.

Missing ages should be coded as “missing”.

## Sex

Sex should be coded as characters.

Valid sexes in the csverse format
Value | class | Definition
--- | --- | ---
"male" | character | Male
"female" | character | Female
"missing" | character | Missing/unknown
"total" | character | Everyone

Missing sexes should be coded as “missing”.