<?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 Simple Macro to Use Today() in Where Function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Simple-Macro-to-Use-Today-in-Where-Function/m-p/447785#M112553</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My over-research for something that I believe should be simple has caused me to be terribly confused on how to use today() function in a where statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A column in my data is in the date format&amp;nbsp;DATETIME22.3. I simply want to create subset that excludes any observations with a date greater than today.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All I want is to be able to reference today as a macro &amp;amp;today. as&amp;nbsp;&lt;SPAN&gt;DATETIME22.3.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Autumn&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*this gives me 0 observations because today() appears to be a different format than activity_date_update*/

data latest_activity1;
set latest_activity;
if activity_date_update &amp;gt; today() then delete;
run;

/*this macros I found on my research appear to be used on for character macros*/

data _null_;
   call symputx('dt',put(date(),yymmddn8.);
run;

data latest_activity1;
set latest_activity;
if activity_date_update &amp;gt; &amp;amp;dt. then delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 22 Mar 2018 14:42:10 GMT</pubDate>
    <dc:creator>akovach</dc:creator>
    <dc:date>2018-03-22T14:42:10Z</dc:date>
    <item>
      <title>Simple Macro to Use Today() in Where Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-Macro-to-Use-Today-in-Where-Function/m-p/447785#M112553</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My over-research for something that I believe should be simple has caused me to be terribly confused on how to use today() function in a where statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A column in my data is in the date format&amp;nbsp;DATETIME22.3. I simply want to create subset that excludes any observations with a date greater than today.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All I want is to be able to reference today as a macro &amp;amp;today. as&amp;nbsp;&lt;SPAN&gt;DATETIME22.3.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Autumn&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*this gives me 0 observations because today() appears to be a different format than activity_date_update*/

data latest_activity1;
set latest_activity;
if activity_date_update &amp;gt; today() then delete;
run;

/*this macros I found on my research appear to be used on for character macros*/

data _null_;
   call symputx('dt',put(date(),yymmddn8.);
run;

data latest_activity1;
set latest_activity;
if activity_date_update &amp;gt; &amp;amp;dt. then delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Mar 2018 14:42:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-Macro-to-Use-Today-in-Where-Function/m-p/447785#M112553</guid>
      <dc:creator>akovach</dc:creator>
      <dc:date>2018-03-22T14:42:10Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Marco to Use Today() in Where Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-Macro-to-Use-Today-in-Where-Function/m-p/447786#M112554</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SInce your column is in datetime format you can not compare it directly to a date.&lt;/P&gt;
&lt;P&gt;Use the datepart function to extract the date from datetime.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where datepart(activity_date_update)&amp;gt;today();&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 14:42:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-Macro-to-Use-Today-in-Where-Function/m-p/447786#M112554</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-03-22T14:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Marco to Use Today() in Where Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-Macro-to-Use-Today-in-Where-Function/m-p/447787#M112555</link>
      <description>&lt;P&gt;Thank you very much, my google searches let me down a very different path.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 14:20:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-Macro-to-Use-Today-in-Where-Function/m-p/447787#M112555</guid>
      <dc:creator>akovach</dc:creator>
      <dc:date>2018-03-22T14:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Marco to Use Today() in Where Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-Macro-to-Use-Today-in-Where-Function/m-p/447795#M112558</link>
      <description>&lt;P&gt;Pet peeve mixing up date and datetime values.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/200580"&gt;@akovach&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A column in my data is in the&lt;STRONG&gt;&lt;FONT color="#ff0000"&gt; date&lt;/FONT&gt; &lt;/STRONG&gt;format&amp;nbsp;&lt;STRONG&gt;&lt;FONT color="#800080"&gt;DATETIME22.3&lt;/FONT&gt;&lt;/STRONG&gt;. I simply want to create subset that excludes any observations with a date greater than today.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In SAS dates and datetimes are measured in different units: date uses days and datetime uses seconds. Proper use of the values involved will help in the long term.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 14:30:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-Macro-to-Use-Today-in-Where-Function/m-p/447795#M112558</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-22T14:30:44Z</dc:date>
    </item>
  </channel>
</rss>

