<?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: How to calculate difference between two dates in different row and column? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-difference-between-two-dates-in-different-row/m-p/608765#M177197</link>
    <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Mon, 02 Dec 2019 16:34:45 GMT</pubDate>
    <dc:creator>huhuhu</dc:creator>
    <dc:date>2019-12-02T16:34:45Z</dc:date>
    <item>
      <title>How to calculate difference between two dates in different row and column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-difference-between-two-dates-in-different-row/m-p/591632#M169526</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm wondering if there is a way to calculate the difference between two dates in different variables listed in different rows. My data looks like below:&lt;/P&gt;&lt;P&gt;MemberID&amp;nbsp; &amp;nbsp;InDate&amp;nbsp; &amp;nbsp; &amp;nbsp;OutDate&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1/1/2019&amp;nbsp; &amp;nbsp;1/3/2019&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1/4/2019&amp;nbsp; &amp;nbsp;1/7/2019&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1/15/2019&amp;nbsp; &amp;nbsp;1/16/2019&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1/20/2019&amp;nbsp; &amp;nbsp; 1/25/2019&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result that I'd like to have is&lt;/P&gt;&lt;P&gt;MemberID&amp;nbsp; &amp;nbsp;InDate&amp;nbsp; &amp;nbsp; &amp;nbsp;OutDate&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; IntervalDays&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1/1/2019&amp;nbsp; &amp;nbsp;1/3/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1/4/2019&amp;nbsp; &amp;nbsp;1/7/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 (difference between 1/4/2019 and 1/3/2019)&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1/15/2019&amp;nbsp; &amp;nbsp;1/16/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1/20/2019&amp;nbsp; &amp;nbsp; 1/25/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4(difference between 1/20/2019 and 1/16/2019)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any advice will be helpful!!&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2019 17:50:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-difference-between-two-dates-in-different-row/m-p/591632#M169526</guid>
      <dc:creator>huhuhu</dc:creator>
      <dc:date>2019-09-25T17:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate difference between two dates in different row and column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-difference-between-two-dates-in-different-row/m-p/591633#M169527</link>
      <description>&lt;P&gt;Use the lag() function to retrieve the value of a variable from the preceding observation.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2019 17:51:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-difference-between-two-dates-in-different-row/m-p/591633#M169527</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-09-25T17:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate difference between two dates in different row and column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-difference-between-two-dates-in-different-row/m-p/591659#M169539</link>
      <description>&lt;P&gt;Please try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input MemberID   InDate:mmddyy10.     OutDate:mmddyy10.;
format InDate OutDate date9.;
cards;
1 1/1/2019   1/3/2019
1 1/4/2019   1/7/2019
2 1/15/2019  1/16/2019
2 1/20/2019  1/25/2019
;

proc sort data=have;
by memberid indate outdate;
run;

data want;
set have;
by memberid indate outdate;
intervaldays=InDate-lag(OutDate);
if first.memberid then intervaldays=.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Sep 2019 18:32:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-difference-between-two-dates-in-different-row/m-p/591659#M169539</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-09-25T18:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate difference between two dates in different row and column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-difference-between-two-dates-in-different-row/m-p/608765#M177197</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2019 16:34:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-difference-between-two-dates-in-different-row/m-p/608765#M177197</guid>
      <dc:creator>huhuhu</dc:creator>
      <dc:date>2019-12-02T16:34:45Z</dc:date>
    </item>
  </channel>
</rss>

