{"id":3551,"date":"2023-08-03T13:10:53","date_gmt":"2023-08-03T12:10:53","guid":{"rendered":"https:\/\/www.microdata.no\/?post_type=eksempel&#038;p=3551"},"modified":"2023-10-27T16:39:19","modified_gmt":"2023-10-27T15:39:19","slug":"facilitating-variables-dummy-and-multicategory-variables-functions-and-labels","status":"publish","type":"eksempel","link":"https:\/\/www.microdata.no\/en\/eksempel\/facilitating-variables-dummy-and-multicategory-variables-functions-and-labels\/","title":{"rendered":"Facilitating variables: Dummy and multicategory variables, functions and labels"},"content":{"rendered":"\n<p>The example below shows different ways of organizing variables, including the use of labels.<\/p>\n\n\n\n<p>Variables that are used as they are, without any kind of processing, already have labels that are displayed when creating statistics. But when organizing and creating new variables and categories, it is useful to create labels to get a better overview of the meaning of the various codes. Labels are created through the <code>define-labels<\/code> command and linked to the relevant variables with the <code>assign-labels<\/code> command. If you create several variables with an identical code list, it is fine to use assign-labels where you refer to already created label set names.<\/p>\n\n\n<div id=\"rose-block_7076592fb57d4c3d1c3753b2eea40388\" class=\"rose-code codeblock-wrapper\">\n<pre tabindex=\"0\" class=\"codeblock\"><code>\/\/ Kobler til databank\r\nrequire no.ssb.fdb:23 as db\r\n\r\n\/\/ Henter variablene en trenger \r\ncreate-dataset demografidata\r\nimport db\/BEFOLKNING_KJOENN as kjonn\r\nimport db\/BEFOLKNING_FOEDSELS_AAR_MND as faarmnd\r\nimport db\/INNTEKT_BRUTTOFORM 2020-01-01 as formue\r\nimport db\/BOSATTEFDT_BOSTED 2020-01-01 as bosted\r\n\r\n\/\/ Beregner alder i 2020 ut i fra f\u00f8dsels\u00e5r \r\ngenerate alder = 2020 - int( faarmnd \/ 100 )\r\n\r\n\/\/ Lager en dummyvariabel som angir mann ut i fra kj\u00f8nn\r\ngenerate mann = 0\r\nreplace mann = 1 if kjonn == '1'\r\n\r\n\/\/ Gruppere formue i 4 intervaller\r\ngenerate formueint = 1\r\nreplace formueint = 2 if formue > 150000\r\nreplace formueint = 3 if formue > 250000\r\nreplace formueint = 4 if formue > 400000\r\n\r\n\/\/ Angi formue i 1000 kr\r\ngenerate formue1000 = formue \/ 1000\r\n\r\n\/\/ Koder om fra kommune- til fylkesniv\u00e5 \r\ngenerate fylke = substr(bosted,1,2)\r\n\r\n\/\/ Legger til verdilabler for \u00e5 navngi fylker med navn (=> penere deskriptiv output) \r\ndefine-labels fylkerstring '03' Oslo '11' Rogaland '15' 'M\u00f8re og Romsdal' '18' Nordland '30' Viken '34' Innlandet '38' 'Vestfold og Telemark' '42' Agder '46' Vestland '50' Tr\u00f8ndelag '54' 'Troms og Finnmark' '21' Spitsbergen '25' 'Utdanning i utlandet' '99' Uoppgitt\r\nassign-labels fylke fylkerstring\r\n\r\ntabulate fylke<\/code><\/pre>\n<\/div>","protected":false},"parent":0,"menu_order":25,"template":"","meta":{"_acf_changed":false,"inline_featured_image":false,"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":""},"class_list":["post-3551","eksempel","type-eksempel","status-publish","hentry"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Facilitating variables: Dummy and multicategory variables, functions and labels - microdata.no<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.microdata.no\/eksempel\/tilrettelegge-variabler-dummy-og-flerkategorivariabler-funksjoner-og-labler\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Facilitating variables: Dummy and multicategory variables, functions and labels - microdata.no\" \/>\n<meta property=\"og:description\" content=\"The example below shows different ways of organizing variables, including the use of labels. Variables that are used as they are, without any kind of processing, already have labels that are displayed when creating statistics. But when organizing and creating new variables and categories, it is useful to create labels to get a better overview...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.microdata.no\/eksempel\/tilrettelegge-variabler-dummy-og-flerkategorivariabler-funksjoner-og-labler\/\" \/>\n<meta property=\"og:site_name\" content=\"microdata.no\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-27T15:39:19+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.microdata.no\\\/eksempel\\\/tilrettelegge-variabler-dummy-og-flerkategorivariabler-funksjoner-og-labler\\\/\",\"url\":\"https:\\\/\\\/www.microdata.no\\\/eksempel\\\/tilrettelegge-variabler-dummy-og-flerkategorivariabler-funksjoner-og-labler\\\/\",\"name\":\"Facilitating variables: Dummy and multicategory variables, functions and labels - microdata.no\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.microdata.no\\\/#website\"},\"datePublished\":\"2023-08-03T12:10:53+00:00\",\"dateModified\":\"2023-10-27T15:39:19+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.microdata.no\\\/eksempel\\\/tilrettelegge-variabler-dummy-og-flerkategorivariabler-funksjoner-og-labler\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.microdata.no\\\/eksempel\\\/tilrettelegge-variabler-dummy-og-flerkategorivariabler-funksjoner-og-labler\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.microdata.no\\\/eksempel\\\/tilrettelegge-variabler-dummy-og-flerkategorivariabler-funksjoner-og-labler\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Hjem\",\"item\":\"https:\\\/\\\/www.microdata.no\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Facilitating variables: Dummy and multicategory variables, functions and labels\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.microdata.no\\\/#website\",\"url\":\"https:\\\/\\\/www.microdata.no\\\/\",\"name\":\"microdata.no\",\"description\":\"Gj\u00f8r det enklere \u00e5 analysere registerdata\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.microdata.no\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Facilitating variables: Dummy and multicategory variables, functions and labels - microdata.no","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.microdata.no\/eksempel\/tilrettelegge-variabler-dummy-og-flerkategorivariabler-funksjoner-og-labler\/","og_locale":"en_US","og_type":"article","og_title":"Facilitating variables: Dummy and multicategory variables, functions and labels - microdata.no","og_description":"The example below shows different ways of organizing variables, including the use of labels. Variables that are used as they are, without any kind of processing, already have labels that are displayed when creating statistics. But when organizing and creating new variables and categories, it is useful to create labels to get a better overview...","og_url":"https:\/\/www.microdata.no\/eksempel\/tilrettelegge-variabler-dummy-og-flerkategorivariabler-funksjoner-og-labler\/","og_site_name":"microdata.no","article_modified_time":"2023-10-27T15:39:19+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.microdata.no\/eksempel\/tilrettelegge-variabler-dummy-og-flerkategorivariabler-funksjoner-og-labler\/","url":"https:\/\/www.microdata.no\/eksempel\/tilrettelegge-variabler-dummy-og-flerkategorivariabler-funksjoner-og-labler\/","name":"Facilitating variables: Dummy and multicategory variables, functions and labels - microdata.no","isPartOf":{"@id":"https:\/\/www.microdata.no\/#website"},"datePublished":"2023-08-03T12:10:53+00:00","dateModified":"2023-10-27T15:39:19+00:00","breadcrumb":{"@id":"https:\/\/www.microdata.no\/eksempel\/tilrettelegge-variabler-dummy-og-flerkategorivariabler-funksjoner-og-labler\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.microdata.no\/eksempel\/tilrettelegge-variabler-dummy-og-flerkategorivariabler-funksjoner-og-labler\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.microdata.no\/eksempel\/tilrettelegge-variabler-dummy-og-flerkategorivariabler-funksjoner-og-labler\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Hjem","item":"https:\/\/www.microdata.no\/en\/"},{"@type":"ListItem","position":2,"name":"Facilitating variables: Dummy and multicategory variables, functions and labels"}]},{"@type":"WebSite","@id":"https:\/\/www.microdata.no\/#website","url":"https:\/\/www.microdata.no\/","name":"microdata.no","description":"Gj\u00f8r det enklere \u00e5 analysere registerdata","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.microdata.no\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"taxonomy_info":[],"featured_image_src_large":[],"author_info":[],"comment_info":"","_links":{"self":[{"href":"https:\/\/www.microdata.no\/en\/wp-json\/wp\/v2\/eksempel\/3551","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.microdata.no\/en\/wp-json\/wp\/v2\/eksempel"}],"about":[{"href":"https:\/\/www.microdata.no\/en\/wp-json\/wp\/v2\/types\/eksempel"}],"wp:attachment":[{"href":"https:\/\/www.microdata.no\/en\/wp-json\/wp\/v2\/media?parent=3551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}