{"id":2358,"date":"2022-06-15T15:38:09","date_gmt":"2022-06-15T14:38:09","guid":{"rendered":"https:\/\/www.microdata.no\/?p=2358"},"modified":"2023-11-22T14:39:07","modified_gmt":"2023-11-22T13:39:07","slug":"now-you-can-restructure-datasets-from-wide-to-long-format","status":"publish","type":"post","link":"https:\/\/www.microdata.no\/en\/now-you-can-restructure-datasets-from-wide-to-long-format\/","title":{"rendered":"Now you can restructure datasets from wide to long format"},"content":{"rendered":"\n<p><strong><em>The new command <code>reshape-to-panel<\/code> gives you the freedom to restructure your data to long-format, i.e. data where the information is organized downwards as observations \/ records.<\/em><\/strong><\/p>\n\n\n\n<!--more-->\n\n\n\n<p>For statistics and analyses in microdata.no, datasets created through the command <code>import<\/code> are normally used. These are data sets of the &#8220;wide&#8221; type, where information about all units in a population is structured horizontally at a variable level. The new <code>reshape-to-panel<\/code> command now makes it possible to change the data structure to long-format (panel-format), where information about each unit (individual) is structured vertically at the observation \/ record level.<\/p>\n\n\n\n<p>Variables that are measured over several times and that you want in long \/ panel format, must be named through <code>reshape-to-panel<\/code> with specified prefixes that consist of the letters (prefix) from the original variable in the wide dataset. Other variables for which no prefix is \u200b\u200bspecified, typically information that is only measured once (gender, country of birth, etc), are automatically defined as fixed information and the values \u200b\u200bfor these are repeated for all sub-levels of each unit.<\/p>\n\n\n\n<p>The illustration below shows how the restructuring takes place under the hood. The example shows a wide-format dataset that contains the variables sivstand18-sivstand20, l\u00f8nn18-l\u00f8nn20, and kj\u00f8nn. Marital status (sivstand) and wage (l\u00f8nn) are thus measured for the years 2018-2020, while gender (kj\u00f8nn) is a fixed piece of information that is only measured once. The dataset is converted to long format using the command <code>reshape-to-panel sivstand l\u00f8nn<\/code>. The variable date@panel is created automatically and contains the sublevel which in this case is a double-digit year.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"656\" height=\"524\" src=\"https:\/\/www.microdata.no\/wp-content\/uploads\/2022\/06\/image-4.png\" alt=\"\" class=\"wp-image-2381\" srcset=\"https:\/\/www.microdata.no\/wp-content\/uploads\/2022\/06\/image-4.png 656w, https:\/\/www.microdata.no\/wp-content\/uploads\/2022\/06\/image-4-300x240.png 300w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><\/figure>\n\n\n\n<p>The <code>reshape-to-panel<\/code> command has several uses:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A more flexible alternative to the <code>import-panel<\/code>, which also creates panel datasets, but which has some limitations. Among other things, all variables here must have valid measurement dates for all measurements, which can be challenging if cross-sectional variables are included in the data set (variables that only have values \u200b\u200bon given annual, quarterly or monthly dates). The <code>reshape-to-panel<\/code> command allows all combinations of variables.<\/li>\n\n\n\n<li>Some analyzes require a long format, and the support for this is now greatly improved. In addition, you have access to all the flexibility and functionalities associated with wide data sets, and can do the entire adaptation in this format before you easily restructure to long format afterwards. This is useful if you need to compare and perform operations over variable values across sub-level (over time), e.g. when creating a condition based upon a comparison between  the value of wages in 2020 and 2019.<\/li>\n<\/ul>\n\n\n\n<p><a href=\"https:\/\/microdata.no\/manual\/en\/eksempel\/Sammensatte%20operasjoner\/Restrukturere%20datasett%20fra%20wide-%20til%20long-format\">Click here for example of using <code>reshape-to-panel<\/code>.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The new command reshape-to-panel gives you the freedom to restructure your data to long-format, i.e. data where the information is organized downwards as observations \/ records.<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","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":"","footnotes":""},"categories":[2],"tags":[],"class_list":["post-2358","post","type-post","status-publish","format-standard","hentry","category-news"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Now you can restructure datasets from wide to long format - 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\/en\/now-you-can-restructure-datasets-from-wide-to-long-format\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Now you can restructure datasets from wide to long format - microdata.no\" \/>\n<meta property=\"og:description\" content=\"The new command reshape-to-panel gives you the freedom to restructure your data to long-format, i.e. data where the information is organized downwards as observations \/ records.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.microdata.no\/en\/now-you-can-restructure-datasets-from-wide-to-long-format\/\" \/>\n<meta property=\"og:site_name\" content=\"microdata.no\" \/>\n<meta property=\"article:published_time\" content=\"2022-06-15T14:38:09+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-22T13:39:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.microdata.no\/wp-content\/uploads\/2022\/06\/image-4.png\" \/>\n<meta name=\"author\" content=\"Trond Pedersen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Trond Pedersen\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.microdata.no\\\/en\\\/now-you-can-restructure-datasets-from-wide-to-long-format\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.microdata.no\\\/en\\\/now-you-can-restructure-datasets-from-wide-to-long-format\\\/\"},\"author\":{\"name\":\"Trond Pedersen\",\"@id\":\"https:\\\/\\\/www.microdata.no\\\/#\\\/schema\\\/person\\\/76761ddfe0d06e3f08f5491a9faeab92\"},\"headline\":\"Now you can restructure datasets from wide to long format\",\"datePublished\":\"2022-06-15T14:38:09+00:00\",\"dateModified\":\"2023-11-22T13:39:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.microdata.no\\\/en\\\/now-you-can-restructure-datasets-from-wide-to-long-format\\\/\"},\"wordCount\":422,\"image\":{\"@id\":\"https:\\\/\\\/www.microdata.no\\\/en\\\/now-you-can-restructure-datasets-from-wide-to-long-format\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.microdata.no\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/image-4.png\",\"articleSection\":[\"News\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.microdata.no\\\/en\\\/now-you-can-restructure-datasets-from-wide-to-long-format\\\/\",\"url\":\"https:\\\/\\\/www.microdata.no\\\/en\\\/now-you-can-restructure-datasets-from-wide-to-long-format\\\/\",\"name\":\"Now you can restructure datasets from wide to long format - microdata.no\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.microdata.no\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.microdata.no\\\/en\\\/now-you-can-restructure-datasets-from-wide-to-long-format\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.microdata.no\\\/en\\\/now-you-can-restructure-datasets-from-wide-to-long-format\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.microdata.no\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/image-4.png\",\"datePublished\":\"2022-06-15T14:38:09+00:00\",\"dateModified\":\"2023-11-22T13:39:07+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.microdata.no\\\/#\\\/schema\\\/person\\\/76761ddfe0d06e3f08f5491a9faeab92\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.microdata.no\\\/en\\\/now-you-can-restructure-datasets-from-wide-to-long-format\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.microdata.no\\\/en\\\/now-you-can-restructure-datasets-from-wide-to-long-format\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.microdata.no\\\/en\\\/now-you-can-restructure-datasets-from-wide-to-long-format\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.microdata.no\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/image-4.png\",\"contentUrl\":\"https:\\\/\\\/www.microdata.no\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/image-4.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.microdata.no\\\/en\\\/now-you-can-restructure-datasets-from-wide-to-long-format\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Hjem\",\"item\":\"https:\\\/\\\/www.microdata.no\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Now you can restructure datasets from wide to long format\"}]},{\"@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\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.microdata.no\\\/#\\\/schema\\\/person\\\/76761ddfe0d06e3f08f5491a9faeab92\",\"name\":\"Trond Pedersen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b90e3f42c839e825d86949fc2f9a318f2a81da5f9e6b1431ff4d872333d4e717?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b90e3f42c839e825d86949fc2f9a318f2a81da5f9e6b1431ff4d872333d4e717?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b90e3f42c839e825d86949fc2f9a318f2a81da5f9e6b1431ff4d872333d4e717?s=96&d=mm&r=g\",\"caption\":\"Trond Pedersen\"},\"url\":\"https:\\\/\\\/www.microdata.no\\\/en\\\/author\\\/trond\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Now you can restructure datasets from wide to long format - 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\/en\/now-you-can-restructure-datasets-from-wide-to-long-format\/","og_locale":"en_US","og_type":"article","og_title":"Now you can restructure datasets from wide to long format - microdata.no","og_description":"The new command reshape-to-panel gives you the freedom to restructure your data to long-format, i.e. data where the information is organized downwards as observations \/ records.","og_url":"https:\/\/www.microdata.no\/en\/now-you-can-restructure-datasets-from-wide-to-long-format\/","og_site_name":"microdata.no","article_published_time":"2022-06-15T14:38:09+00:00","article_modified_time":"2023-11-22T13:39:07+00:00","og_image":[{"url":"https:\/\/www.microdata.no\/wp-content\/uploads\/2022\/06\/image-4.png","type":"","width":"","height":""}],"author":"Trond Pedersen","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Trond Pedersen","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.microdata.no\/en\/now-you-can-restructure-datasets-from-wide-to-long-format\/#article","isPartOf":{"@id":"https:\/\/www.microdata.no\/en\/now-you-can-restructure-datasets-from-wide-to-long-format\/"},"author":{"name":"Trond Pedersen","@id":"https:\/\/www.microdata.no\/#\/schema\/person\/76761ddfe0d06e3f08f5491a9faeab92"},"headline":"Now you can restructure datasets from wide to long format","datePublished":"2022-06-15T14:38:09+00:00","dateModified":"2023-11-22T13:39:07+00:00","mainEntityOfPage":{"@id":"https:\/\/www.microdata.no\/en\/now-you-can-restructure-datasets-from-wide-to-long-format\/"},"wordCount":422,"image":{"@id":"https:\/\/www.microdata.no\/en\/now-you-can-restructure-datasets-from-wide-to-long-format\/#primaryimage"},"thumbnailUrl":"https:\/\/www.microdata.no\/wp-content\/uploads\/2022\/06\/image-4.png","articleSection":["News"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.microdata.no\/en\/now-you-can-restructure-datasets-from-wide-to-long-format\/","url":"https:\/\/www.microdata.no\/en\/now-you-can-restructure-datasets-from-wide-to-long-format\/","name":"Now you can restructure datasets from wide to long format - microdata.no","isPartOf":{"@id":"https:\/\/www.microdata.no\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.microdata.no\/en\/now-you-can-restructure-datasets-from-wide-to-long-format\/#primaryimage"},"image":{"@id":"https:\/\/www.microdata.no\/en\/now-you-can-restructure-datasets-from-wide-to-long-format\/#primaryimage"},"thumbnailUrl":"https:\/\/www.microdata.no\/wp-content\/uploads\/2022\/06\/image-4.png","datePublished":"2022-06-15T14:38:09+00:00","dateModified":"2023-11-22T13:39:07+00:00","author":{"@id":"https:\/\/www.microdata.no\/#\/schema\/person\/76761ddfe0d06e3f08f5491a9faeab92"},"breadcrumb":{"@id":"https:\/\/www.microdata.no\/en\/now-you-can-restructure-datasets-from-wide-to-long-format\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.microdata.no\/en\/now-you-can-restructure-datasets-from-wide-to-long-format\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.microdata.no\/en\/now-you-can-restructure-datasets-from-wide-to-long-format\/#primaryimage","url":"https:\/\/www.microdata.no\/wp-content\/uploads\/2022\/06\/image-4.png","contentUrl":"https:\/\/www.microdata.no\/wp-content\/uploads\/2022\/06\/image-4.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.microdata.no\/en\/now-you-can-restructure-datasets-from-wide-to-long-format\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Hjem","item":"https:\/\/www.microdata.no\/en\/"},{"@type":"ListItem","position":2,"name":"Now you can restructure datasets from wide to long format"}]},{"@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"},{"@type":"Person","@id":"https:\/\/www.microdata.no\/#\/schema\/person\/76761ddfe0d06e3f08f5491a9faeab92","name":"Trond Pedersen","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/b90e3f42c839e825d86949fc2f9a318f2a81da5f9e6b1431ff4d872333d4e717?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/b90e3f42c839e825d86949fc2f9a318f2a81da5f9e6b1431ff4d872333d4e717?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b90e3f42c839e825d86949fc2f9a318f2a81da5f9e6b1431ff4d872333d4e717?s=96&d=mm&r=g","caption":"Trond Pedersen"},"url":"https:\/\/www.microdata.no\/en\/author\/trond\/"}]}},"taxonomy_info":{"category":[{"value":2,"label":"News"}]},"featured_image_src_large":false,"author_info":{"display_name":"Trond Pedersen","author_link":"https:\/\/www.microdata.no\/en\/author\/trond\/"},"comment_info":0,"category_info":[{"term_id":2,"name":"News","slug":"news","term_group":0,"term_taxonomy_id":2,"taxonomy":"category","description":"","parent":0,"count":79,"filter":"raw","cat_ID":2,"category_count":79,"category_description":"","cat_name":"News","category_nicename":"news","category_parent":0}],"tag_info":false,"_links":{"self":[{"href":"https:\/\/www.microdata.no\/en\/wp-json\/wp\/v2\/posts\/2358","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.microdata.no\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.microdata.no\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.microdata.no\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.microdata.no\/en\/wp-json\/wp\/v2\/comments?post=2358"}],"version-history":[{"count":18,"href":"https:\/\/www.microdata.no\/en\/wp-json\/wp\/v2\/posts\/2358\/revisions"}],"predecessor-version":[{"id":3829,"href":"https:\/\/www.microdata.no\/en\/wp-json\/wp\/v2\/posts\/2358\/revisions\/3829"}],"wp:attachment":[{"href":"https:\/\/www.microdata.no\/en\/wp-json\/wp\/v2\/media?parent=2358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.microdata.no\/en\/wp-json\/wp\/v2\/categories?post=2358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.microdata.no\/en\/wp-json\/wp\/v2\/tags?post=2358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}