<?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 Re: 18 Month Date Range with Overlapping Dates in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/18-Month-Date-Range-with-Overlapping-Dates/m-p/529082#M5528</link>
    <description>&lt;P&gt;This worked! Thank you!!&lt;/P&gt;</description>
    <pubDate>Tue, 22 Jan 2019 15:31:07 GMT</pubDate>
    <dc:creator>A_Halps</dc:creator>
    <dc:date>2019-01-22T15:31:07Z</dc:date>
    <item>
      <title>18 Month Date Range with Overlapping Dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/18-Month-Date-Range-with-Overlapping-Dates/m-p/529051#M5522</link>
      <description>&lt;P&gt;I am trying to look at an 18 month range of dates and label them properly. However, some of the dates overlap.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, some of the date ranges will be "7/1/02 - 12/31/03", "7/1/03 - 12/31/04", and "7/1/04 - 12/31/05". I want to a make a new column to show if a specific date is in that date range or not. The only issue I keep having is the overlapping dates. I want to duplicate a row if it is in both date ranges so that new column I created will say each date range. For example, 11/1/03 is in both "7/1/02 - 12/31/03" and "7/1/03 - 12/31/04". So I want the row of data where exam_dt = 11/1/03 to be duplicated so new_exam_date will have one row that says "7/1/02 - 12/31/03" and another row that says "7/1/03 - 12/31/04".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now, I have the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data symptoms_new_date;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;set symptoms;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if exam_dt ge '01jul2001'd and exam_dt le '31dec2002'd&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;then new_exam_date="7/1/01 - 12/31/02";&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;else if exam_dt ge '01jul2002'd and exam_dt le '31dec2003'd&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;then new_exam_date="7/1/02 - 12/31/03";&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;else if exam_dt ge '01jul2003'd and exam_dt le '31dec2004'd&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;then new_exam_date="7/1/03 - 12/31/04";&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;else if exam_dt ge '01jul2004'd and exam_dt le '31dec2005'd&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;then new_exam_date="7/1/04 - 12/31/05";&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;else new_exam_date=0;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 14:29:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/18-Month-Date-Range-with-Overlapping-Dates/m-p/529051#M5522</guid>
      <dc:creator>A_Halps</dc:creator>
      <dc:date>2019-01-22T14:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: 18 Month Date Range with Overlapping Dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/18-Month-Date-Range-with-Overlapping-Dates/m-p/529056#M5523</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use multiple IF-THEN conditions to create multiple columns based on the date range, later you can use these new columns created to identify if the date falls in more than one group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data symptoms_new_date;
    set symptoms;
        if exam_dt ge '01jul2001'd and exam_dt le '31dec2002'd
            then date1="7/1/01 - 12/31/02";
        if exam_dt ge '01jul2002'd and exam_dt le '31dec2003'd
            then date2="7/1/02 - 12/31/03";
        if exam_dt ge '01jul2003'd and exam_dt le '31dec2004'd
            then date3="7/1/03 - 12/31/04";
        if exam_dt ge '01jul2004'd and exam_dt le '31dec2005'd
            then date4="7/1/04 - 12/31/05";			
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Jan 2019 14:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/18-Month-Date-Range-with-Overlapping-Dates/m-p/529056#M5523</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2019-01-22T14:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: 18 Month Date Range with Overlapping Dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/18-Month-Date-Range-with-Overlapping-Dates/m-p/529069#M5524</link>
      <description>&lt;P&gt;Thank you, but how would I continue with the following if I used your method:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;create table symptoms_18_mo as&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;select b.*&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;from arep.pop_2018 a&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;left join Symptoms_new_date b&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;on a.study_id=b.study_id&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;group by a.study_id, b.new_exam_date;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;create table check_symptoms as&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;select distinct new_exam_date,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;count(*) as total,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;sum(cough) as cough_abs,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(gerd) as gerd_abs,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from symptoms_18_mo&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;group by new_exam_date;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;proc sort data=symptoms_18_mo;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;by new_exam_date;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc freq data=symptoms_18_mo;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;tables new_exam_date* (cough gerd)&amp;nbsp; / missing nopercent;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 15:04:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/18-Month-Date-Range-with-Overlapping-Dates/m-p/529069#M5524</guid>
      <dc:creator>A_Halps</dc:creator>
      <dc:date>2019-01-22T15:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: 18 Month Date Range with Overlapping Dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/18-Month-Date-Range-with-Overlapping-Dates/m-p/529074#M5525</link>
      <description>&lt;P&gt;Your program is almost there, but:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;You are using&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ... then ...&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if ... then&amp;nbsp;...&lt;BR /&gt;sequences.&amp;nbsp; This means that a date that could satisfy 2 if tests will only be subject to 1 of the THEN actions,&amp;nbsp; This is because, once a condition is satisfied&amp;nbsp;the ELSE usage prevents consideration of subsequent conditions.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;Once you've solved the above, you should issue an OUTPUT statement for each satisfied condition.&amp;nbsp; This will allow you to duplicate rows when a date falls into 2 date ranges:&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data symptoms_new_date;
    set symptoms;
        if exam_dt ge '01jul2001'd and exam_dt le '31dec2002'd then do;
          new_exam_date="7/1/01 - 12/31/02";
          output;
        end;
        if exam_dt ge '01jul2002'd and exam_dt le '31dec2003'd then do;
          new_exam_date="7/1/02 - 12/31/03";
          output;
        end;
        if exam_dt ge '01jul2003'd and exam_dt le '31dec2004'd then do;
          new_exam_date="7/1/03 - 12/31/04";
          output;
        end;
        if exam_dt ge '01jul2004'd and exam_dt le '31dec2005'd then do;
          new_exam_date="7/1/04 - 12/31/05";
          output;
        end;
		if exam_dt lt '01jul2001'd or exam_dt&amp;gt;'31dec2005'd then do;
          new_exam_date=0;
          output;
        end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 15:18:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/18-Month-Date-Range-with-Overlapping-Dates/m-p/529074#M5525</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-01-22T15:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: 18 Month Date Range with Overlapping Dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/18-Month-Date-Range-with-Overlapping-Dates/m-p/529077#M5526</link>
      <description>&lt;P&gt;Create the column you require at the end of the if condition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new_exam_date=catx(" ",date1,date2,date3,date4);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will show the two groups if the date exists in both.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide some sample data and your required output for more specific solution.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 15:23:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/18-Month-Date-Range-with-Overlapping-Dates/m-p/529077#M5526</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2019-01-22T15:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: 18 Month Date Range with Overlapping Dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/18-Month-Date-Range-with-Overlapping-Dates/m-p/529082#M5528</link>
      <description>&lt;P&gt;This worked! Thank you!!&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 15:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/18-Month-Date-Range-with-Overlapping-Dates/m-p/529082#M5528</guid>
      <dc:creator>A_Halps</dc:creator>
      <dc:date>2019-01-22T15:31:07Z</dc:date>
    </item>
  </channel>
</rss>

