<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Dates with case statement to get flag in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Dates-with-case-statement-to-get-flag/m-p/495174#M130636</link>
    <description>&lt;P&gt;Hi Techies,&lt;/P&gt;&lt;P&gt;I came across a requirement which is taking a lot of time for me. Could you please help.&lt;BR /&gt;I have two data sets DS1 and DS2.&lt;/P&gt;&lt;P&gt;DS1:&lt;/P&gt;&lt;P&gt;EMP_ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;role&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WORK_ST_DT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;WORK_EN_DT&lt;BR /&gt;236107&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 31/01/2012&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02/01/2013&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01/01/2014&lt;BR /&gt;236107&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25/03/2014&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02/04/2014&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 05/06/2014&lt;BR /&gt;236107&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 31/12/2014&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;31/01/2014&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30/06/2014&lt;/P&gt;&lt;P&gt;DS2:&lt;/P&gt;&lt;P&gt;EMP_ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ST_DT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; END_DT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; IND&lt;BR /&gt;236017&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01/01/2013&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 31/06/2013&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Y&lt;BR /&gt;263107&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20/02/2014&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;30/03/2014&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) My first requirement is to get the indicator from DS2 when ds1.DT is between dates DS2.ST_DT and DS2.END_DT,&lt;BR /&gt;if DS1.DT is not in a range(role 1 in this case ) then I have to go with DS1.WORK_ST_DT lies between DS2.ST_DT and DS2.END_DT and pick the indicator ( in this case rol 1 gets Y ).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) If DS1.DT and DS1.WORK_ST_DT ARE not in any range then I have to select the previous indicator.&lt;BR /&gt;ex: the role 3 DS1.DT and DS1.WORK_ST_DT ARE NOT not in a range for DS2.ST_DT and DS2.END_DT then I have to get Y Indicator, which is the previous indicator.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;When these two tables are joined there is where condition DS1.EMP_ID = DS2.EMP_ID AND DS1.DT LIES between DS2.ST_DT and DS2.END_DT. This is the existing code on top of that I have to make the chnages.&lt;/P&gt;&lt;P&gt;I have tried to give more information as I can, sorry if I make you confused.&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Vickys&lt;/P&gt;</description>
    <pubDate>Thu, 13 Sep 2018 06:35:29 GMT</pubDate>
    <dc:creator>vickys</dc:creator>
    <dc:date>2018-09-13T06:35:29Z</dc:date>
    <item>
      <title>Dates with case statement to get flag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dates-with-case-statement-to-get-flag/m-p/495174#M130636</link>
      <description>&lt;P&gt;Hi Techies,&lt;/P&gt;&lt;P&gt;I came across a requirement which is taking a lot of time for me. Could you please help.&lt;BR /&gt;I have two data sets DS1 and DS2.&lt;/P&gt;&lt;P&gt;DS1:&lt;/P&gt;&lt;P&gt;EMP_ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;role&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WORK_ST_DT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;WORK_EN_DT&lt;BR /&gt;236107&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 31/01/2012&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02/01/2013&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01/01/2014&lt;BR /&gt;236107&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25/03/2014&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02/04/2014&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 05/06/2014&lt;BR /&gt;236107&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 31/12/2014&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;31/01/2014&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30/06/2014&lt;/P&gt;&lt;P&gt;DS2:&lt;/P&gt;&lt;P&gt;EMP_ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ST_DT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; END_DT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; IND&lt;BR /&gt;236017&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01/01/2013&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 31/06/2013&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Y&lt;BR /&gt;263107&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20/02/2014&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;30/03/2014&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) My first requirement is to get the indicator from DS2 when ds1.DT is between dates DS2.ST_DT and DS2.END_DT,&lt;BR /&gt;if DS1.DT is not in a range(role 1 in this case ) then I have to go with DS1.WORK_ST_DT lies between DS2.ST_DT and DS2.END_DT and pick the indicator ( in this case rol 1 gets Y ).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) If DS1.DT and DS1.WORK_ST_DT ARE not in any range then I have to select the previous indicator.&lt;BR /&gt;ex: the role 3 DS1.DT and DS1.WORK_ST_DT ARE NOT not in a range for DS2.ST_DT and DS2.END_DT then I have to get Y Indicator, which is the previous indicator.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;When these two tables are joined there is where condition DS1.EMP_ID = DS2.EMP_ID AND DS1.DT LIES between DS2.ST_DT and DS2.END_DT. This is the existing code on top of that I have to make the chnages.&lt;/P&gt;&lt;P&gt;I have tried to give more information as I can, sorry if I make you confused.&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Vickys&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 06:35:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dates-with-case-statement-to-get-flag/m-p/495174#M130636</guid>
      <dc:creator>vickys</dc:creator>
      <dc:date>2018-09-13T06:35:29Z</dc:date>
    </item>
    <item>
      <title>Re: Dates with case statement to get flag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dates-with-case-statement-to-get-flag/m-p/495189#M130646</link>
      <description>&lt;P&gt;Yes, that is confusing.&amp;nbsp; Please start by posting test data in the form of a datastep, so that we can run it and have some data to play with.&amp;nbsp; Then show what the output should look like.&lt;/P&gt;
&lt;P&gt;I am going to take a stab at:&lt;/P&gt;
&lt;P&gt;Do an SQL statment which merge the data per 1)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will give you a dataset with all the information and additional variables.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next do a datastep and if those variables are present ue that, other lag() the previous result in&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 08:12:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dates-with-case-statement-to-get-flag/m-p/495189#M130646</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-13T08:12:40Z</dc:date>
    </item>
  </channel>
</rss>

