<?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: Use today()- days with macro date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Use-today-days-with-macro-date/m-p/601756#M174101</link>
    <description>&lt;P&gt;I beg to differ. &amp;nbsp; I almost always use human-readable date values for macrovars - but always in the DATE9 format.&amp;nbsp; I find this user-friendly and easy to use, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; %let cutoff_date=07oct2015;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then in my programs I just use statements such as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; where date &amp;gt;= "&amp;amp;cutoff_date"d;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I would avoid like the plague using any other date specification in macrovars.&lt;/P&gt;</description>
    <pubDate>Tue, 05 Nov 2019 18:39:08 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2019-11-05T18:39:08Z</dc:date>
    <item>
      <title>Use today()- days with macro date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-today-days-with-macro-date/m-p/601642#M174050</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a code that will append information to an existing table last day of each month. Now I want to append historic data and my thoughts are that I can use the same method like "today()-30" to get previous months, but instead with my macro variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone tell me if this pink idea below will work? Or have a better idea.&lt;/P&gt;&lt;P&gt;date="&amp;amp;todaysDate"d&lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;()-30&lt;/STRONG&gt;&lt;/FONT&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Susannah&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 12:34:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-today-days-with-macro-date/m-p/601642#M174050</guid>
      <dc:creator>SURIM</dc:creator>
      <dc:date>2019-11-05T12:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: Use today()- days with macro date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-today-days-with-macro-date/m-p/601645#M174052</link>
      <description>&lt;P&gt;If &amp;amp;todaysdate contains a date in the date9. format, &lt;EM&gt;and&lt;/EM&gt; you omit the brackets (they were part of the function call).&lt;/P&gt;
&lt;P&gt;If you define macro variable todaysdate without a format, it's even simpler:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let todaysdate=%sysfunc(today());

data test;
date = &amp;amp;todaysdate. - 30;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that if you want to get the date of a month back, you're better off using the intnx() function.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 12:47:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-today-days-with-macro-date/m-p/601645#M174052</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-05T12:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: Use today()- days with macro date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-today-days-with-macro-date/m-p/601652#M174054</link>
      <description>&lt;P&gt;First, as usual&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;gives very good advice. I would like to add that when creating macro variables, I never use formatted (human readable) values of those macro variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let todaysdate=%sysfunc(today());
%put &amp;amp;=todaysdate;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;produces the value 21858, which is how SAS stores dates, as the number of days since January 1, 1960 and &lt;EM&gt;this is fine for all macro computations and all macro work&lt;/EM&gt;, and this is also easier than working with formatted values. The only time you need it to appear formatted such as 05NOV19 is when you need to report something that a human will need to understand, and only at that point in time do I format the macro variable value.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 13:03:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-today-days-with-macro-date/m-p/601652#M174054</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-05T13:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: Use today()- days with macro date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-today-days-with-macro-date/m-p/601661#M174057</link>
      <description>&lt;P&gt;Thanks a lot for your fast reply!&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 13:35:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-today-days-with-macro-date/m-p/601661#M174057</guid>
      <dc:creator>SURIM</dc:creator>
      <dc:date>2019-11-05T13:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: Use today()- days with macro date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-today-days-with-macro-date/m-p/601662#M174058</link>
      <description>Good advice, thanks you!</description>
      <pubDate>Tue, 05 Nov 2019 13:36:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-today-days-with-macro-date/m-p/601662#M174058</guid>
      <dc:creator>SURIM</dc:creator>
      <dc:date>2019-11-05T13:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: Use today()- days with macro date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-today-days-with-macro-date/m-p/601756#M174101</link>
      <description>&lt;P&gt;I beg to differ. &amp;nbsp; I almost always use human-readable date values for macrovars - but always in the DATE9 format.&amp;nbsp; I find this user-friendly and easy to use, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; %let cutoff_date=07oct2015;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then in my programs I just use statements such as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; where date &amp;gt;= "&amp;amp;cutoff_date"d;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I would avoid like the plague using any other date specification in macrovars.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2019 18:39:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-today-days-with-macro-date/m-p/601756#M174101</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-11-05T18:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: Use today()- days with macro date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-today-days-with-macro-date/m-p/601988#M174220</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I like this more "simple" solutions, and I realised now that I didn't specify that&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. I want to deploy the code automatically in the future, so I need a date this is not manually entered.&lt;/P&gt;&lt;P&gt;2. The date is not just the last day of each month, I want the SAS sytem to act as if the entered date is today, so to speak. That's why I involved the sysfunc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I also like the dates formatted upfront since I work a lot with order dates and first purchase dates, it makes it more easy to follow.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2019 14:06:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-today-days-with-macro-date/m-p/601988#M174220</guid>
      <dc:creator>SURIM</dc:creator>
      <dc:date>2019-11-06T14:06:45Z</dc:date>
    </item>
  </channel>
</rss>

