<?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: Counting Dates Question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Counting-Dates-Question/m-p/349377#M81023</link>
    <description>&lt;P&gt;Something like this in a DATA step should work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if closed_date &amp;gt; . then days_open = closed_date - start_date;&lt;/P&gt;
&lt;P&gt;else days _open = today() - start_date;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are minor efficiency considerations that could avoid calling the TODAY() function so many times. &amp;nbsp;But that would be way down the list of priorities.&lt;/P&gt;</description>
    <pubDate>Wed, 12 Apr 2017 11:33:41 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-04-12T11:33:41Z</dc:date>
    <item>
      <title>Counting Dates Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-Dates-Question/m-p/349372#M81020</link>
      <description>&lt;P&gt;So I have two sets of dates one is Start_Date the other Closed_Date. &amp;nbsp;Start_Date is always populated, however Closed_Date can be null. &amp;nbsp;I have a formula in Excel that does the job, but I wanted to migrate this into SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Excel Formula:&amp;nbsp;=IF(I5="", TODAY() - H5,I5-H5)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So what I am trying to do is if Closed_Date is null then take today's date and subtract the Start_Date which will give me days open. &amp;nbsp;However if the Closed_Date has a value, subtract that value from the Start_Date to give me days open.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How would I transform this excel code into SAS code?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 11:13:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-Dates-Question/m-p/349372#M81020</guid>
      <dc:creator>IgawaKei29</dc:creator>
      <dc:date>2017-04-12T11:13:51Z</dc:date>
    </item>
    <item>
      <title>Re: Counting Dates Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-Dates-Question/m-p/349377#M81023</link>
      <description>&lt;P&gt;Something like this in a DATA step should work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if closed_date &amp;gt; . then days_open = closed_date - start_date;&lt;/P&gt;
&lt;P&gt;else days _open = today() - start_date;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are minor efficiency considerations that could avoid calling the TODAY() function so many times. &amp;nbsp;But that would be way down the list of priorities.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 11:33:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-Dates-Question/m-p/349377#M81023</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-12T11:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: Counting Dates Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Counting-Dates-Question/m-p/349388#M81031</link>
      <description>&lt;P&gt;Thank you this is perfect. &amp;nbsp;I had to play around with the dates a little, but once I did the count worked perfectly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data work.test;
 set work.extract;
  format closed_date start_date date9.;
 
   closed_date=datepart(closed_date);
   start_date=datepart(start_date);


    if closed_date &amp;gt; . then days_open = closed_date - start_date;
    else days_open = today() - start_date;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Apr 2017 11:51:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Counting-Dates-Question/m-p/349388#M81031</guid>
      <dc:creator>IgawaKei29</dc:creator>
      <dc:date>2017-04-12T11:51:34Z</dc:date>
    </item>
  </channel>
</rss>

