{"id":1519,"date":"2022-02-25T17:40:12","date_gmt":"2022-02-25T16:40:12","guid":{"rendered":"https:\/\/microdata.spirehost.no\/?post_type=eksempel&#038;p=1519"},"modified":"2023-08-18T13:31:05","modified_gmt":"2023-08-18T12:31:05","slug":"create-couples-datasets","status":"publish","type":"eksempel","link":"https:\/\/www.microdata.no\/en\/eksempel\/create-couples-datasets\/","title":{"rendered":"Create couples datasets"},"content":{"rendered":"\n<p>Microdata.no offers a number of demographic variables that make it possible to find, among other things, spouses, cohabitants and partners, and use this to link information about both members of the couple for use in various analyses.<\/p>\n\n\n\n<p>The variable <em>BEFOLKNING_REGSTAT_FAMNR<\/em> contains the family identity number of each individual, where all family members have the same value for the family number. This can be used to create family information or to aggregate data up to family level. And since the family number is defined by the personal identity number of the oldest person in the family, you can use this in combination with other family information to find people who live together as a couple (spouses, cohabitants, partners):<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Start by creating a data set consisting of information about:\n<ul class=\"wp-block-list\">\n<li>Family number<\/li>\n\n\n\n<li>Personal code<\/li>\n\n\n\n<li>Couple status (optional)<\/li>\n\n\n\n<li>Desired information additional information, e.g. occupation<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Select the oldest person in each family. Use the variable personcode for this (personcode = &#8216;1&#8217;)<\/li>\n\n\n\n<li>Create a new data set where you import the same variables, but where you select the youngest person in each family (personcode = &#8216;2&#8217;). Children are kept out as they have their own personal code (personcode = &#8216;3&#8217;).<\/li>\n\n\n\n<li>Move over again to the data set with the oldest, and link the relevant variables together with the data set for the youngest. Since the youngest have information about who is the oldest in the family (= the family number), this can be used as a linking key and the result is a data set for all couples.<\/li>\n\n\n\n<li>Finally, move over to the dataset of the youngest. This now contains all your data for both couple members, for every couples in your population.<\/li>\n<\/ol>\n\n\n\n<p><\/p>\n\n\n<div id=\"rose-block_04830d5ff38347e82d379e0b19c192ba\" class=\"rose-code codeblock-wrapper\">\n<pre tabindex=\"0\" class=\"codeblock\"><code>\/\/Connect to database\r\nrequire no.ssb.fdb:23 as ds\r\n\r\n\/\/Create dataset consisting of oldest person in each family\r\ncreate-dataset oldest\r\nimport ds\/BEFOLKNING_REGSTAT_FAMNR 2021-01-01 as famnr\r\nimport ds\/BEFOLKNING_REGSTAT_PERSONKODE 2021-01-01 as personcode_oldest\r\nimport ds\/BEFOLKNING_PARSTATUS 2021-01-01 as couplestatus_oldest\r\nimport ds\/REGSYS_ARB_YRKE_STYRK08 2020-11-16 as occupation_oldest\r\nkeep if personcode_oldest == '1'\r\n\r\n\/\/Create dataset consisting of youngest person in each family, that are not children\r\ncreate-dataset youngest\r\nimport ds\/BEFOLKNING_REGSTAT_FAMNR 2021-01-01 as famnr\r\nimport ds\/BEFOLKNING_REGSTAT_PERSONKODE 2021-01-01 as personcode_youngest\r\nimport ds\/BEFOLKNING_PARSTATUS 2021-01-01 as couplestatus_youngest\r\nimport ds\/REGSYS_ARB_YRKE_STYRK08 2020-11-16 as occupation_youngest\r\nkeep if personcode_youngest == '2'\r\n\r\n\/\/Use dataset with oldest persons and link the variables into the dataset with the youngest persons via family number (family number = oldest person id-number)\r\nuse oldest\r\nmerge personcode_oldest couplestatus_oldest occupation_oldest into youngest on famnr \r\n\r\n\/\/The dataset youngest now contains data on both spouses\/couple members for all couples in the population. Run controle tabulations\r\nuse youngest\r\ntabulate personcode_youngest, missing\r\ntabulate personcode_oldest, missing\r\ntabulate couplestatus_youngest, missing\r\ntabulate couplestatus_oldest, missing\r\ntabulate occupation_oldest, missing\r\ntabulate occupation_youngest, missing\r\n\r\n\/\/Check if both, one or none of the spouses\/couple members are working\r\ngenerate job_youngest = 1 if sysmiss(occupation_youngest) == 0\r\ngenerate job_oldest = 1 if sysmiss(occupation_oldest) == 0\r\ntabulate job_oldest job_youngest, missing<\/code><\/pre>\n<\/div>","protected":false},"parent":0,"menu_order":109,"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-1519","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>Create couples datasets - 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\/lage-datasett-bestaende-av-ektefeller-og-par\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create couples datasets - microdata.no\" \/>\n<meta property=\"og:description\" content=\"Microdata.no offers a number of demographic variables that make it possible to find, among other things, spouses, cohabitants and partners, and use this to link information about both members of the couple for use in various analyses. The variable BEFOLKNING_REGSTAT_FAMNR contains the family identity number of each individual, where all family members have the same...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.microdata.no\/eksempel\/lage-datasett-bestaende-av-ektefeller-og-par\/\" \/>\n<meta property=\"og:site_name\" content=\"microdata.no\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-18T12:31:05+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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.microdata.no\\\/eksempel\\\/lage-datasett-bestaende-av-ektefeller-og-par\\\/\",\"url\":\"https:\\\/\\\/www.microdata.no\\\/eksempel\\\/lage-datasett-bestaende-av-ektefeller-og-par\\\/\",\"name\":\"Create couples datasets - microdata.no\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.microdata.no\\\/#website\"},\"datePublished\":\"2022-02-25T16:40:12+00:00\",\"dateModified\":\"2023-08-18T12:31:05+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.microdata.no\\\/eksempel\\\/lage-datasett-bestaende-av-ektefeller-og-par\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.microdata.no\\\/eksempel\\\/lage-datasett-bestaende-av-ektefeller-og-par\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.microdata.no\\\/eksempel\\\/lage-datasett-bestaende-av-ektefeller-og-par\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Hjem\",\"item\":\"https:\\\/\\\/www.microdata.no\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Create couples datasets\"}]},{\"@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":"Create couples datasets - 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\/lage-datasett-bestaende-av-ektefeller-og-par\/","og_locale":"en_US","og_type":"article","og_title":"Create couples datasets - microdata.no","og_description":"Microdata.no offers a number of demographic variables that make it possible to find, among other things, spouses, cohabitants and partners, and use this to link information about both members of the couple for use in various analyses. The variable BEFOLKNING_REGSTAT_FAMNR contains the family identity number of each individual, where all family members have the same...","og_url":"https:\/\/www.microdata.no\/eksempel\/lage-datasett-bestaende-av-ektefeller-og-par\/","og_site_name":"microdata.no","article_modified_time":"2023-08-18T12:31:05+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.microdata.no\/eksempel\/lage-datasett-bestaende-av-ektefeller-og-par\/","url":"https:\/\/www.microdata.no\/eksempel\/lage-datasett-bestaende-av-ektefeller-og-par\/","name":"Create couples datasets - microdata.no","isPartOf":{"@id":"https:\/\/www.microdata.no\/#website"},"datePublished":"2022-02-25T16:40:12+00:00","dateModified":"2023-08-18T12:31:05+00:00","breadcrumb":{"@id":"https:\/\/www.microdata.no\/eksempel\/lage-datasett-bestaende-av-ektefeller-og-par\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.microdata.no\/eksempel\/lage-datasett-bestaende-av-ektefeller-og-par\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.microdata.no\/eksempel\/lage-datasett-bestaende-av-ektefeller-og-par\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Hjem","item":"https:\/\/www.microdata.no\/en\/"},{"@type":"ListItem","position":2,"name":"Create couples datasets"}]},{"@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\/1519","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=1519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}