# csdata

`csdata` provides structural data for Norway.

Please see https://www.csids.no/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 | Norge | Norge | Norge
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) | Alstahaug_kommune_i_Nordland | Alstahaug_kommune_i_Nordland
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) | Alna_bydel_i_Oslo | Alna_bydel_i_Oslo
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) | Marka_bydel_i_Oslo | Marka_bydel_i_Oslo
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) | Ukjent_bydel_i_Oslo | Ukjent_bydel_i_Oslo
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
baregion6 | 159 | baregion_nor111 | Alstahaug | Alstahaug (BA-region) | Alstahaug_BA_region | Alstahaug_BA_region
georegion7 | 5 | georegion_nor1 | Nord-Norge | Nord-Norge (landsdel) | Nord_Norge_landsdel | Nord_Norge_landsdel
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 Bo- og arbeidsmarkedsregioner. Housing and labor market regions.
7 Landsdeler/riskdeler. Geographical 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”.