{"id":382,"date":"2015-08-21T17:16:48","date_gmt":"2015-08-21T21:16:48","guid":{"rendered":"http:\/\/csclub.uwaterloo.ca\/~k55chen\/?p=382"},"modified":"2017-10-29T00:12:05","modified_gmt":"2017-10-29T04:12:05","slug":"if-beginning-year-and-ending-year-are-known-how-to-fill-in-years-in-between","status":"publish","type":"post","link":"https:\/\/www.kaichen.work\/?p=382","title":{"rendered":"If beginning year and ending year are known, how to fill in years in between?"},"content":{"rendered":"<p><span style=\"text-decoration: underline;\"><strong>Question:<\/strong><\/span><\/p>\n<p>Suppose two companies A and B are connected in some years. Say, right now the data structure is the following:<\/p>\n<p>Company 1 Company 2 Starting Year Ending Year<br \/>\nA B 2000 2006<br \/>\nA C 1998 2003<br \/>\nC D 1995 1997<\/p>\n<p>I want to find a way to generate:<\/p>\n<p>Company 1 Company 2 Year<br \/>\nA B 2000<br \/>\nA B 2001<br \/>\n\u2026\u2026\u2026\u2026\u2026.<br \/>\nA B 2006<br \/>\nA C 1998<br \/>\n\u2026\u2026\u2026\u2026\u2026..<br \/>\nA C 2003<br \/>\nC D 1995<br \/>\n\u2026\u2026\u2026\u2026\u2026..<br \/>\nC D 1997<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Answer:<\/strong><\/span><\/p>\n<pre class=\"lang:default decode:true \">DATA temp01;\r\n   INPUT id1 id2 year1 year2;\r\n   DATALINES;\r\n     100  501  1999   2003\r\n     200  688  2007   2011\r\n     333  777  1995   2008;\r\nrun;\r\n \r\ndata temp02;\r\n   set temp01;\r\n   do i= 0 to (year2-year1);\r\n      year=year1+i;\r\n      output;\r\n   end;\r\n   keep id1 id2 year;\r\nrun;<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Question: Suppose two companies A and B are connected in some years. Say, right now the data structure is the following: Company 1 Company 2 Starting Year Ending Year A B 2000 2006 A C 1998 2003 C D 1995 &hellip; <a href=\"https:\/\/www.kaichen.work\/?p=382\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"_links":{"self":[{"href":"https:\/\/www.kaichen.work\/index.php?rest_route=\/wp\/v2\/posts\/382"}],"collection":[{"href":"https:\/\/www.kaichen.work\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kaichen.work\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kaichen.work\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kaichen.work\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=382"}],"version-history":[{"count":5,"href":"https:\/\/www.kaichen.work\/index.php?rest_route=\/wp\/v2\/posts\/382\/revisions"}],"predecessor-version":[{"id":971,"href":"https:\/\/www.kaichen.work\/index.php?rest_route=\/wp\/v2\/posts\/382\/revisions\/971"}],"wp:attachment":[{"href":"https:\/\/www.kaichen.work\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kaichen.work\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kaichen.work\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}