<?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: overlapping date observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/overlapping-date-observations/m-p/322721#M71425</link>
    <description>&lt;P&gt;Thanks! worked well.&lt;/P&gt;</description>
    <pubDate>Thu, 05 Jan 2017 17:07:22 GMT</pubDate>
    <dc:creator>terjeph</dc:creator>
    <dc:date>2017-01-05T17:07:22Z</dc:date>
    <item>
      <title>overlapping date observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/overlapping-date-observations/m-p/322653#M71401</link>
      <description>&lt;P&gt;I've got dates describing periodes (start end) and a variable describing waiting time (wt). However, the dates are partialle overlapping. This is nearly fixed in the attached program but I would like to have latest observation of wt to be placed in correctly. Anyone?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 13:27:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/overlapping-date-observations/m-p/322653#M71401</guid>
      <dc:creator>terjeph</dc:creator>
      <dc:date>2017-01-05T13:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: overlapping date observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/overlapping-date-observations/m-p/322695#M71416</link>
      <description>&lt;P&gt;You have similar situation as in next post.See solution - it fits your case:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/General-SAS-Programming/Sorting-overlapping-dates-and-address-histories/td-p/315687" target="_self"&gt;https://communities.sas.com/t5/General-SAS-Programming/Sorting-overlapping-dates-and-address-histories/td-p/315687&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 16:03:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/overlapping-date-observations/m-p/322695#M71416</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-05T16:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: overlapping date observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/overlapping-date-observations/m-p/322709#M71422</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I got this right, you just need to sort the data correctly and fetch the previous stdate between by groups.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;* sort reversing stdate (recent to later);&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;proc sort data=waits;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;by hospid diag descending stdate;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;* adjust overlapping between by groups;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;data waits2;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;set waits;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;format stdate enddate date9.;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;drop _:; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;by hospid diag;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &lt;STRONG&gt;&amp;nbsp;* fetch previous stdate;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;_enddate=lag1(stdate);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;* skip first by group row, fix overlapping;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if not first.diag then enddate=min(enddate,_enddate-1);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;* sort back (later to recent);&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;proc sort;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;by hospid diag stdate;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;run&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;lag&lt;EM&gt;N&lt;/EM&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;functions will retrieve the previous &lt;EM&gt;Nth&lt;/EM&gt;&amp;nbsp;row value of &lt;STRONG&gt;PDV&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;More here:&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212547.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212547.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The rest is just pure data step logic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Daniel Santos&amp;nbsp;@ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 17:20:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/overlapping-date-observations/m-p/322709#M71422</guid>
      <dc:creator>Daniel-Santos</dc:creator>
      <dc:date>2017-01-05T17:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: overlapping date observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/overlapping-date-observations/m-p/322721#M71425</link>
      <description>&lt;P&gt;Thanks! worked well.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 17:07:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/overlapping-date-observations/m-p/322721#M71425</guid>
      <dc:creator>terjeph</dc:creator>
      <dc:date>2017-01-05T17:07:22Z</dc:date>
    </item>
  </channel>
</rss>

