<?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: Compare a Date stored within a Macro variable to a list of Datetime in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Compare-a-Date-stored-within-a-Macro-variable-to-a-list-of/m-p/664287#M22851</link>
    <description>&lt;P&gt;Do not format macro variables, that makes it only harder to use them.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
call symputx("cutoff",input("20200622",yymmdd8.));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you can compare them to the datepart of a datetime value:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input dt :datetime19.;
format dt datetime19.;
del = &amp;amp;cutoff. gt datepart(dt);
datalines;
01JAN2020:01:00:02
23jun2020:01:00:02
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 23 Jun 2020 13:50:03 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-06-23T13:50:03Z</dc:date>
    <item>
      <title>Compare a Date stored within a Macro variable to a list of Datetime</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Compare-a-Date-stored-within-a-Macro-variable-to-a-list-of/m-p/664264#M22849</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a macro variable with the following date: "20200622" (yymmddn8. format). What I need to do is to compare it to a list of Datetime values (e.g.&amp;nbsp;01JAN2020:01:00:02) in order to exclude those that are less or equal to the date stored within the macro variable.&lt;/P&gt;&lt;P&gt;What am I supposed to do? I am a bit lost. Any help is appreciated. Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2020 13:00:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Compare-a-Date-stored-within-a-Macro-variable-to-a-list-of/m-p/664264#M22849</guid>
      <dc:creator>salvavit</dc:creator>
      <dc:date>2020-06-23T13:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: Compare a Date stored within a Macro variable to a list of Datetime</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Compare-a-Date-stored-within-a-Macro-variable-to-a-list-of/m-p/664287#M22851</link>
      <description>&lt;P&gt;Do not format macro variables, that makes it only harder to use them.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
call symputx("cutoff",input("20200622",yymmdd8.));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you can compare them to the datepart of a datetime value:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input dt :datetime19.;
format dt datetime19.;
del = &amp;amp;cutoff. gt datepart(dt);
datalines;
01JAN2020:01:00:02
23jun2020:01:00:02
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Jun 2020 13:50:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Compare-a-Date-stored-within-a-Macro-variable-to-a-list-of/m-p/664287#M22851</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-23T13:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: Compare a Date stored within a Macro variable to a list of Datetime</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Compare-a-Date-stored-within-a-Macro-variable-to-a-list-of/m-p/664348#M22853</link>
      <description>&lt;P&gt;Hello Kurt and thanks for the reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actually, I might have solved the issue in the meantime, although using a different solution than yours. This is what I wrote:&lt;/P&gt;&lt;PRE&gt;data table_2 (drop=day_p);
set table_1;
day_pp = datepart(input(day_p,yymmddn8.));
run;

data table_3 (rename=day_pp = day_p);
set table_2;
where put(day_pp, yymmddn8.) &amp;gt;= "&amp;amp;MACRODATE";
run;&lt;/PRE&gt;&lt;P&gt;It seems to be working.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2020 15:15:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Compare-a-Date-stored-within-a-Macro-variable-to-a-list-of/m-p/664348#M22853</guid>
      <dc:creator>salvavit</dc:creator>
      <dc:date>2020-06-23T15:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: Compare a Date stored within a Macro variable to a list of Datetime</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Compare-a-Date-stored-within-a-Macro-variable-to-a-list-of/m-p/664352#M22854</link>
      <description>&lt;P&gt;This is also valid, because the format in the PUT function tells everybody how the value in the macro variable should be formatted.&lt;/P&gt;
&lt;P&gt;Personally, I prefer the "raw" method, as I can directly compare the SAS dates without using a PUT or INPUT function.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2020 15:22:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Compare-a-Date-stored-within-a-Macro-variable-to-a-list-of/m-p/664352#M22854</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-23T15:22:43Z</dc:date>
    </item>
  </channel>
</rss>

