{"id":3531,"date":"2023-07-18T14:08:05","date_gmt":"2023-07-18T13:08:05","guid":{"rendered":"https:\/\/www.microdata.no\/?post_type=eksempel&#038;p=3531"},"modified":"2023-10-27T16:39:19","modified_gmt":"2023-10-27T15:39:19","slug":"descriptive-statistics-tabulate","status":"publish","type":"eksempel","link":"https:\/\/www.microdata.no\/en\/eksempel\/descriptive-statistics-tabulate\/","title":{"rendered":"Descriptive statistics: tabulate"},"content":{"rendered":"\n<p>The script below demonstrates different ways to use the <code>tabulate<\/code> command to create descriptive statistics.<\/p>\n\n\n\n<p>The command is used on categorical variables to produce frequency tables, both unidimensional and multidimensional. By combining with the <code>summarize()<\/code> option, you can also create volume tables.<\/p>\n\n\n\n<p>Both numeric and alphanumeric variables can be used as input, but the number of cells in the table must not exceed a certain limit. E.g. you can make a table of all municipalities (distributed by gender etc), but not of all education codes.<\/p>\n\n\n<div id=\"rose-block_6678bfaf5ecdd88aa9c3997052b889cb\" class=\"rose-code codeblock-wrapper\">\n<pre tabindex=\"0\" class=\"codeblock\"><code>require no.ssb.fdb:23 as db\r\n\r\ncreate-dataset demografidata\r\nimport db\/INNTEKT_WYRKINNT 2020-01-01 as innt\r\nimport db\/INNTEKT_BRUTTOFORM 2020-01-01 as formue\r\nimport db\/BEFOLKNING_KJOENN as kj\u00f8nn\r\nimport db\/BEFOLKNING_FOEDSELS_AAR_MND as faarmnd\r\nimport db\/SIVSTANDFDT_SIVSTAND 2016-01-01 as sivstand16\r\nimport db\/SIVSTANDFDT_SIVSTAND 2020-01-01 as sivstand20\r\nimport db\/BOSATTEFDT_BOSTED 2020-01-01 as bosted\r\nimport db\/BEFOLKNING_STATUSKODE 2020-01-01 as regstat\r\n\r\n\/\/ Koder om fra kommune- til fylkesniv\u00e5 \r\ngenerate fylke = substr(bosted,1, 2)\r\n\r\n\r\n\/\/ Genererer deskriptiv statistikk\r\n\r\n\/\/ Frekvenstabeller - enveis og toveis\r\n\/\/ Den beste m\u00e5ten \u00e5 gj\u00f8re seg kjent med diskrete variabler er gjennom frekvenstabeller. Disse viser antallet enheter for hver kategori, og gir dessuten overblikk over hvilke kategorier som benyttes for den aktuelle variabelen. En kan se p\u00e5 enkeltvariabler gjennom enveistabeller, men ogs\u00e5 kombinere to eller flere i en og samme tabell (krysstabeller). Dette gir innblikk i hvordan frekvensene fordeler seg, kontrollert for verdier p\u00e5 andre variabler\r\n\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\n\r\nassign-labels fylke fylkerstring\r\n\r\ntabulate fylke\r\ntabulate kj\u00f8nn\r\ntabulate kj\u00f8nn regstat\r\ntabulate kj\u00f8nn fylke\r\n\r\n\/\/ Krysstabell med kun kategoriverdier (ikke labler)\r\ntabulate kj\u00f8nn regstat fylke, nolabels\r\n\r\n\/\/ Krysstabell der missingverdier tas med \r\ntabulate fylke regstat, missing\r\n\r\n\/\/ Krysstabell der vi bare viser resultatet for personer over 30 \u00e5r\r\ngenerate alder = 2020 - int(faarmnd\/100)\r\ntabulate fylke regstat if alder > 30\r\n\r\n\/\/ Prosenttabeller\r\ntabulate sivstand16 sivstand20, rowpct\r\ntabulate sivstand16 sivstand20, colpct\r\ntabulate sivstand16 sivstand20, cellpct\r\ntabulate sivstand16 sivstand20, rowpct freq\r\n\r\n\/\/ tabulate-kommandoen kan ogs\u00e5 brukes til \u00e5 lage volumtabeller vha. summarize-option. Dette viser statistikk som gjennomsnitt m.m. for en gitt variabel fordelt p\u00e5 kategorier spesifisert gjennom de valgte tabulate-variable\r\n\r\ntabulate fylke kj\u00f8nn, summarize(formue)<\/code><\/pre>\n<\/div>","protected":false},"parent":0,"menu_order":27,"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-3531","eksempel","type-eksempel","status-publish","hentry"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Descriptive statistics: tabulate - 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\/deskriptiv-statistikk-tabulate\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Descriptive statistics: tabulate - microdata.no\" \/>\n<meta property=\"og:description\" content=\"The script below demonstrates different ways to use the tabulate command to create descriptive statistics. The command is used on categorical variables to produce frequency tables, both unidimensional and multidimensional. By combining with the summarize() option, you can also create volume tables. Both numeric and alphanumeric variables can be used as input, but the number...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.microdata.no\/eksempel\/deskriptiv-statistikk-tabulate\/\" \/>\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\\\/deskriptiv-statistikk-tabulate\\\/\",\"url\":\"https:\\\/\\\/www.microdata.no\\\/eksempel\\\/deskriptiv-statistikk-tabulate\\\/\",\"name\":\"Descriptive statistics: tabulate - microdata.no\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.microdata.no\\\/#website\"},\"datePublished\":\"2023-07-18T13:08:05+00:00\",\"dateModified\":\"2023-10-27T15:39:19+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.microdata.no\\\/eksempel\\\/deskriptiv-statistikk-tabulate\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.microdata.no\\\/eksempel\\\/deskriptiv-statistikk-tabulate\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.microdata.no\\\/eksempel\\\/deskriptiv-statistikk-tabulate\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Hjem\",\"item\":\"https:\\\/\\\/www.microdata.no\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Descriptive statistics: tabulate\"}]},{\"@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":"Descriptive statistics: tabulate - 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\/deskriptiv-statistikk-tabulate\/","og_locale":"en_US","og_type":"article","og_title":"Descriptive statistics: tabulate - microdata.no","og_description":"The script below demonstrates different ways to use the tabulate command to create descriptive statistics. The command is used on categorical variables to produce frequency tables, both unidimensional and multidimensional. By combining with the summarize() option, you can also create volume tables. Both numeric and alphanumeric variables can be used as input, but the number...","og_url":"https:\/\/www.microdata.no\/eksempel\/deskriptiv-statistikk-tabulate\/","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\/deskriptiv-statistikk-tabulate\/","url":"https:\/\/www.microdata.no\/eksempel\/deskriptiv-statistikk-tabulate\/","name":"Descriptive statistics: tabulate - microdata.no","isPartOf":{"@id":"https:\/\/www.microdata.no\/#website"},"datePublished":"2023-07-18T13:08:05+00:00","dateModified":"2023-10-27T15:39:19+00:00","breadcrumb":{"@id":"https:\/\/www.microdata.no\/eksempel\/deskriptiv-statistikk-tabulate\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.microdata.no\/eksempel\/deskriptiv-statistikk-tabulate\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.microdata.no\/eksempel\/deskriptiv-statistikk-tabulate\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Hjem","item":"https:\/\/www.microdata.no\/en\/"},{"@type":"ListItem","position":2,"name":"Descriptive statistics: tabulate"}]},{"@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\/3531","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=3531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}