<?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 Retaining specific period of time in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Retaining-specific-period-of-time/m-p/494177#M130185</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id start_Dt dx_dt end_dt qt;
format start_Dt dx_dt end_dt mmddyy10.;
cards;
1  1/1/2005 1/2/2005  2/2/2005  30
2  3/3/2005 3/4/2005  9/10/2005  5
2  1/4/2006 4/4/2006 5/8/2006   10
2  5/1/2007 5/5/2007 5/7/2007   15
;
run;&lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have the following data. I need to retain any observation were the time between dx_Dt and end_dt is within 7 days of start_dt and keep the qt variable in the output dataset&lt;/P&gt;&lt;P&gt;Output data&lt;/P&gt;&lt;P&gt;1&amp;nbsp; 1/2/2005&amp;nbsp; 1/9/2005&amp;nbsp; 30&lt;/P&gt;&lt;P&gt;2&amp;nbsp; 3/4/2005&amp;nbsp; 3/10/2005 5&lt;/P&gt;</description>
    <pubDate>Mon, 10 Sep 2018 15:51:52 GMT</pubDate>
    <dc:creator>lillymaginta</dc:creator>
    <dc:date>2018-09-10T15:51:52Z</dc:date>
    <item>
      <title>Retaining specific period of time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-specific-period-of-time/m-p/494177#M130185</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id start_Dt dx_dt end_dt qt;
format start_Dt dx_dt end_dt mmddyy10.;
cards;
1  1/1/2005 1/2/2005  2/2/2005  30
2  3/3/2005 3/4/2005  9/10/2005  5
2  1/4/2006 4/4/2006 5/8/2006   10
2  5/1/2007 5/5/2007 5/7/2007   15
;
run;&lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have the following data. I need to retain any observation were the time between dx_Dt and end_dt is within 7 days of start_dt and keep the qt variable in the output dataset&lt;/P&gt;&lt;P&gt;Output data&lt;/P&gt;&lt;P&gt;1&amp;nbsp; 1/2/2005&amp;nbsp; 1/9/2005&amp;nbsp; 30&lt;/P&gt;&lt;P&gt;2&amp;nbsp; 3/4/2005&amp;nbsp; 3/10/2005 5&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 15:51:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-specific-period-of-time/m-p/494177#M130185</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2018-09-10T15:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining specific period of time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-specific-period-of-time/m-p/494179#M130186</link>
      <description>&lt;P&gt;Why is this row not included in the output?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;2  5/1/2007 5/5/2007 5/7/2007   15&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 15:58:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-specific-period-of-time/m-p/494179#M130186</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-09-10T15:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining specific period of time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-specific-period-of-time/m-p/494180#M130187</link>
      <description>&lt;P&gt;Sorry Paige, I meant and so on. I just wanted to give an example of the output for the first two.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 16:01:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-specific-period-of-time/m-p/494180#M130187</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2018-09-10T16:01:15Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining specific period of time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-specific-period-of-time/m-p/494182#M130188</link>
      <description>&lt;P&gt;Well, if I am understanding the request properly, then this should work (note: there is no data set named WANT produced, all of this is done when creating data set HAVE)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id start_Dt dx_dt end_dt qt;
if dx_dt-start_dt&amp;lt;=7 or end_dt-start_dt&amp;lt;=7 then output;
informat start_Dt dx_dt end_dt mmddyy10.;
format start_Dt dx_dt end_dt mmddyy10.;
cards;
1  1/1/2005 1/2/2005  2/2/2005  30
2  3/3/2005 3/4/2005  9/10/2005  5
2  1/4/2006 4/4/2006 5/8/2006   10
2  5/1/2007 5/5/2007 5/7/2007   15
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 16:05:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-specific-period-of-time/m-p/494182#M130188</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-09-10T16:05:55Z</dc:date>
    </item>
  </channel>
</rss>

