<?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: Calculate difference in days between SAS dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculate-difference-in-days-between-SAS-dates/m-p/532715#M145989</link>
    <description>&lt;P&gt;For number of days between two SAS dates, you can just subtract one from the other. Behind the scenes, a SAS date is just a number (# of days since Jan. 1, 1960).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
 date1='01JAN2019'd;
 date2='04FEB2019'd;
 days_between=date2 - date1;
* format date1 date2 mmddyy10.;
run;

proc print data=x; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want the number of weeks, months, quarters, etc. between two SAS dates, check out the intck() function.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Feb 2019 20:18:08 GMT</pubDate>
    <dc:creator>ChanceTGardener</dc:creator>
    <dc:date>2019-02-04T20:18:08Z</dc:date>
    <item>
      <title>Calculate difference in days between SAS dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-difference-in-days-between-SAS-dates/m-p/532705#M145981</link>
      <description>&lt;P&gt;Hi.&amp;nbsp; I'm wondering what would be the best way to determine the number of days between two SAS date variables and return it as a number variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggests would be very helpful.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2019 20:09:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-difference-in-days-between-SAS-dates/m-p/532705#M145981</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2019-02-04T20:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference in days between SAS dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-difference-in-days-between-SAS-dates/m-p/532706#M145982</link>
      <description>Depends a bit on your data structure, but you can just subtract dates to get durations.</description>
      <pubDate>Mon, 04 Feb 2019 20:10:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-difference-in-days-between-SAS-dates/m-p/532706#M145982</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-04T20:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference in days between SAS dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-difference-in-days-between-SAS-dates/m-p/532708#M145983</link>
      <description>&lt;P&gt;Use the INTCK Function like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   date1='01jan2019'd;
   date2=today();
   days=intck('day', date1, date2);
   put days=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Feb 2019 20:11:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-difference-in-days-between-SAS-dates/m-p/532708#M145983</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-02-04T20:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference in days between SAS dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-difference-in-days-between-SAS-dates/m-p/532712#M145986</link>
      <description>&lt;P&gt;What do you mean depending on data structure?&amp;nbsp; As an example I'd be looking at dates stored like:&lt;/P&gt;&lt;P&gt;03-FEB-2019 minus 01-FEB-2019 to return 2 as the number of days.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does that make sense?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2019 20:16:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-difference-in-days-between-SAS-dates/m-p/532712#M145986</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2019-02-04T20:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference in days between SAS dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-difference-in-days-between-SAS-dates/m-p/532715#M145989</link>
      <description>&lt;P&gt;For number of days between two SAS dates, you can just subtract one from the other. Behind the scenes, a SAS date is just a number (# of days since Jan. 1, 1960).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
 date1='01JAN2019'd;
 date2='04FEB2019'd;
 days_between=date2 - date1;
* format date1 date2 mmddyy10.;
run;

proc print data=x; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want the number of weeks, months, quarters, etc. between two SAS dates, check out the intck() function.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2019 20:18:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-difference-in-days-between-SAS-dates/m-p/532715#M145989</guid>
      <dc:creator>ChanceTGardener</dc:creator>
      <dc:date>2019-02-04T20:18:08Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference in days between SAS dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-difference-in-days-between-SAS-dates/m-p/532717#M145991</link>
      <description>&lt;P&gt;It depends on if your dates are SAS dates with a numeric format and not character.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It also depends on whether both dates are in the same line or not - if you need to look behind or forward you would use different techniques. At the end of the day, a difference calculation is all you need.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/79805"&gt;@buechler66&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;What do you mean depending on data structure?&amp;nbsp; As an example I'd be looking at dates stored like:&lt;/P&gt;
&lt;P&gt;03-FEB-2019 minus 01-FEB-2019 to return 2 as the number of days.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does that make sense?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2019 20:20:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-difference-in-days-between-SAS-dates/m-p/532717#M145991</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-04T20:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference in days between SAS dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-difference-in-days-between-SAS-dates/m-p/532731#M145993</link>
      <description>Thanks so much for the example. I appreciate you taking the time.</description>
      <pubDate>Mon, 04 Feb 2019 20:32:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-difference-in-days-between-SAS-dates/m-p/532731#M145993</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2019-02-04T20:32:38Z</dc:date>
    </item>
  </channel>
</rss>

