<?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: Calculating an interval from today's date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculating-an-interval-from-today-s-date/m-p/333216#M75046</link>
    <description>&lt;P&gt;Because your "data data _null_" statement created a dataset named "data", with 1 var and 1 observation.&amp;nbsp; You never called that dataset in proc sql, and it wouldn't have been very useful anyhow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why not use the "today()" function, instead of variable TDAY, &amp;nbsp;inside your proc sql?&lt;/P&gt;</description>
    <pubDate>Wed, 15 Feb 2017 23:09:53 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2017-02-15T23:09:53Z</dc:date>
    <item>
      <title>Calculating an interval from today's date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-an-interval-from-today-s-date/m-p/333214#M75044</link>
      <description>&lt;P&gt;Hi all, newbie question:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I currently have a huge dataset listing thousands of patients and the dates they've had blood drawn on. &amp;nbsp;I'd like to winnow the list down to just the bloods drawn during the&amp;nbsp;week before last to create a less cumbersome working list for those draws. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I found the Today function while poking around online and figured that I could just use that to grab today's date and calculate an interval from that but it isn't working as expected. &amp;nbsp;My code attempt:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data _null_;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; tday=today();&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;proc sql; &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;create table Bloods_Abridged as select distinct patient_number, date_drawn from Bloods_Complete&amp;nbsp;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;where (tday-date_drawn) &amp;lt; 17 and (tday-date_drawn) &amp;gt; 11; quit;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And the resulting error text:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;ERROR: The following columns were not found in the contributing tables: tday.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So clearly I'm messing something up in getting the table to recognize 'tday' but I have no idea what. &amp;nbsp;Also not 100% sure if my code for calculating the interval is correct, since the problem with the table not recognizing 'tday'&amp;nbsp;means I don't even get there. The date_drawn column is in mmddyy10 format, would my code for the interval work if the initialization of today's date worked? &amp;nbsp;Trying this on SAS 9.4. &amp;nbsp;Any help is appreciated, thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 23:04:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-an-interval-from-today-s-date/m-p/333214#M75044</guid>
      <dc:creator>sentientcarbon</dc:creator>
      <dc:date>2017-02-15T23:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating an interval from today's date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-an-interval-from-today-s-date/m-p/333216#M75046</link>
      <description>&lt;P&gt;Because your "data data _null_" statement created a dataset named "data", with 1 var and 1 observation.&amp;nbsp; You never called that dataset in proc sql, and it wouldn't have been very useful anyhow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why not use the "today()" function, instead of variable TDAY, &amp;nbsp;inside your proc sql?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 23:09:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-an-interval-from-today-s-date/m-p/333216#M75046</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-02-15T23:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating an interval from today's date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-an-interval-from-today-s-date/m-p/333221#M75048</link>
      <description>&lt;P&gt;Aaaaaaaand that worked perfectly, thanks! &amp;nbsp;Just deleted the data step and changed the proc step to this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;proc sql;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;create table Bloods_Abridged as select distinct patient_number, date_drawn from Bloods_Complete&amp;nbsp;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;where (today()-date_drawn) &amp;lt; 17 and (today()-date_drawn) &amp;gt; 11; quit;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And it gave me exactly what I wanted. &amp;nbsp;The weird initial format was from me copying the Today function code straight off the support.sas site thinking I shouldn't mess with it since I pretty much only know enough SAS to break stuff &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 23:19:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-an-interval-from-today-s-date/m-p/333221#M75048</guid>
      <dc:creator>sentientcarbon</dc:creator>
      <dc:date>2017-02-15T23:19:07Z</dc:date>
    </item>
  </channel>
</rss>

