<?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: subtraction date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/subtraction-date/m-p/708380#M217695</link>
    <description>&lt;P&gt;Given that both are character variables, you have to convert from character to numeric on the fly, as part of the computation:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;diff_days = input(finished_date, mmddyy10.) - input(start_date, mmddyy10.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This assumes that the time values are part of FINISHED_DATE, not part of START_DATE.&amp;nbsp; Even then, there could be complications if you have 8-character dates with a time piece like 2/6/2017 9:28.&amp;nbsp; If that occurs, a slightly more complex formula would be needed.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Dec 2020 03:34:39 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2020-12-28T03:34:39Z</dc:date>
    <item>
      <title>subtraction date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/subtraction-date/m-p/708372#M217693</link>
      <description>&lt;P&gt;Someone passed me date variables like that follows.&amp;nbsp; Both&amp;nbsp;Finished_date (Char 15 $15. $15.) and Start_date (Char 10 ) are characters.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I'd like to compute difference in days between&amp;nbsp;Finished_date&amp;nbsp; and Start_date; that is, Diff_days =&amp;nbsp;Finished_date - Start_date, but it does not work. How can I do this simple subtraction? convert character to date format first?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your help! Lee&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Finished_date Start_date&lt;BR /&gt;2/15/2020 10/15/2018&lt;BR /&gt;2/15/2020 3/1/2018&lt;BR /&gt;2/15/2020 7/8/2018&lt;BR /&gt;2/16/2020 9:28 8/20/2019&lt;BR /&gt;2/16/2020 12:44 1/1/2017&lt;BR /&gt;2/17/2020 0:10 9/25/2016&lt;BR /&gt;2/17/2020 7:54 10/15/2019&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2020 00:33:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/subtraction-date/m-p/708372#M217693</guid>
      <dc:creator>leeshea06</dc:creator>
      <dc:date>2020-12-28T00:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: subtraction date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/subtraction-date/m-p/708380#M217695</link>
      <description>&lt;P&gt;Given that both are character variables, you have to convert from character to numeric on the fly, as part of the computation:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;diff_days = input(finished_date, mmddyy10.) - input(start_date, mmddyy10.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This assumes that the time values are part of FINISHED_DATE, not part of START_DATE.&amp;nbsp; Even then, there could be complications if you have 8-character dates with a time piece like 2/6/2017 9:28.&amp;nbsp; If that occurs, a slightly more complex formula would be needed.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2020 03:34:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/subtraction-date/m-p/708380#M217695</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-12-28T03:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: subtraction date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/subtraction-date/m-p/708381#M217696</link>
      <description>&lt;P&gt;I would play it safe and go with :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;diff_days = input(scan(finished_date, 1, " "), mmddyy10.) - input(scan(start_date, 1, " "), mmddyy10.);&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2020 04:45:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/subtraction-date/m-p/708381#M217696</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-12-28T04:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: subtraction date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/subtraction-date/m-p/708422#M217715</link>
      <description>works, thanks! Lee</description>
      <pubDate>Mon, 28 Dec 2020 14:11:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/subtraction-date/m-p/708422#M217715</guid>
      <dc:creator>leeshea06</dc:creator>
      <dc:date>2020-12-28T14:11:06Z</dc:date>
    </item>
  </channel>
</rss>

