<?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: Macro Dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431271#M106643</link>
    <description>&lt;P&gt;Assuming you balance the parentheses:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let Dartmouth =%sysfunc(intnx(month,%sysfunc(today()), -1),date9.);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You still haven't told us why the program should return a particular day of the month instead of the 1st day of the month.&amp;nbsp; What reason is there for picking the 8th or the 12th instead of the 1st?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Taking a wild stab at the reason, that it should be the same day of the month as when you run the program, here is something you can add:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let Dartmouth =%sysfunc(intnx(month,%sysfunc(today()),-1, same),date9.);&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 26 Jan 2018 14:14:59 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-01-26T14:14:59Z</dc:date>
    <item>
      <title>Macro Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431239#M106628</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Currently within my SAS code there is a date macro&lt;BR /&gt;&lt;BR /&gt;%let datemonth =04jan2018&lt;BR /&gt;&lt;BR /&gt;Next month it could read&lt;BR /&gt;&lt;BR /&gt;%let datemonth =12feb2018&lt;BR /&gt;&lt;BR /&gt;So the day of the month changes. My macro for automation doesn't seem to work for this reason I think when I write this&lt;BR /&gt;&lt;BR /&gt;%let Dartmouth =%sysfunc(intnx(month,%sysfunc(today())),-1),date9.));&lt;BR /&gt;&lt;BR /&gt;Any ideas how to correct the macro please?&lt;BR /&gt;</description>
      <pubDate>Fri, 26 Jan 2018 12:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431239#M106628</guid>
      <dc:creator>Brandon16</dc:creator>
      <dc:date>2018-01-26T12:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431243#M106630</link>
      <description>&lt;P&gt;You have 4 opening, but 6 closing parenthesis.&lt;/P&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let datemonth=%sysfunc(intnx(month,%sysfunc(today()),-1),date9.);
%put &amp;amp;datemonth;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Jan 2018 12:46:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431243#M106630</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-26T12:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431271#M106643</link>
      <description>&lt;P&gt;Assuming you balance the parentheses:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let Dartmouth =%sysfunc(intnx(month,%sysfunc(today()), -1),date9.);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You still haven't told us why the program should return a particular day of the month instead of the 1st day of the month.&amp;nbsp; What reason is there for picking the 8th or the 12th instead of the 1st?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Taking a wild stab at the reason, that it should be the same day of the month as when you run the program, here is something you can add:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let Dartmouth =%sysfunc(intnx(month,%sysfunc(today()),-1, same),date9.);&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 14:14:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431271#M106643</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-01-26T14:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431288#M106653</link>
      <description>The dataset is named by date depending on when it was created which is why the day can change.</description>
      <pubDate>Fri, 26 Jan 2018 14:53:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431288#M106653</guid>
      <dc:creator>Brandon16</dc:creator>
      <dc:date>2018-01-26T14:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431291#M106655</link>
      <description>&lt;P&gt;For that, you don't need a program.&amp;nbsp; There is an automatic macro variable (you already have it) named &amp;amp;SYSDATE9 that contains that exact information.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 15:08:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431291#M106655</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-01-26T15:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431294#M106658</link>
      <description>I still can't get it to work. When I key in the %let date manually, it works as expected. As soon as I revert to the Macro, it doesn't match. No idea why.</description>
      <pubDate>Fri, 26 Jan 2018 15:19:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431294#M106658</guid>
      <dc:creator>Brandon16</dc:creator>
      <dc:date>2018-01-26T15:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431309#M106667</link>
      <description>&lt;P&gt;Then post the log of the method that does not work as expected. Use the {i} icon for this.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 15:45:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431309#M106667</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-26T15:45:40Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431319#M106671</link>
      <description>&lt;P&gt;Are you really creating a macro variable named Dartmouth ?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make sure you reference the same macro variable you create.&lt;/P&gt;
&lt;P&gt;If you are running the %LET inside of a macro then make sure to define the macro variable as global before creating it or else it will be local and disappear when the macro finishes running.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 16:02:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431319#M106671</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-01-26T16:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431328#M106676</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/188367"&gt;@Brandon16&lt;/a&gt; wrote:&lt;BR /&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Currently within my SAS code there is a date macro&lt;BR /&gt;&lt;BR /&gt;%let datemonth =04jan2018&lt;BR /&gt;&lt;BR /&gt;Next month it could read&lt;BR /&gt;&lt;BR /&gt;%let datemonth =12feb2018&lt;BR /&gt;&lt;BR /&gt;So the day of the month changes. My macro for automation doesn't seem to work for this reason I think when I write this&lt;BR /&gt;&lt;BR /&gt;%let Dartmouth =%sysfunc(intnx(month,%sysfunc(today())),-1),date9.));&lt;BR /&gt;&lt;BR /&gt;Any ideas how to correct the macro please?&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You should show how code is currently actually using the macro variable &lt;STRONG&gt;DATEMONTH &lt;/STRONG&gt;(likely not Dartmouth).&lt;/P&gt;
&lt;P&gt;The %sysfunc approach is going to yield the unformatted numeric version of the date such as 21227 for 12Feb2018, not the DATE9 version.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also&lt;/P&gt;
&lt;P&gt;Doesn't work is awful vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of a dataset, the actual results and the expected results. Data should be in the form of a data step. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat&lt;/A&gt;... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 16:09:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431328#M106676</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-26T16:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431334#M106680</link>
      <description>Dartmouth was a typo sorry.&lt;BR /&gt;&lt;BR /&gt;I have a proc tabulate and class displays as expected when NOT using the automated Macro, however when I try to use the automated Macro, the class is aggregated up as a total</description>
      <pubDate>Fri, 26 Jan 2018 16:16:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431334#M106680</guid>
      <dc:creator>Brandon16</dc:creator>
      <dc:date>2018-01-26T16:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431336#M106682</link>
      <description>&lt;P&gt;CODE.AND.LOG.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 16:20:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Dates/m-p/431336#M106682</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-26T16:20:30Z</dc:date>
    </item>
  </channel>
</rss>

