<?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 creating a macro of month names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/creating-a-macro-of-month-names/m-p/464428#M118409</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create&amp;nbsp;macros that create month names&lt;/P&gt;&lt;P&gt;l need the macro to be able to create the exact&amp;nbsp;last month even though if it last year.&lt;/P&gt;&lt;P&gt;last time I created this macro to&amp;nbsp;create last month&amp;nbsp;# by the macro below&amp;nbsp; but I also need the month name too&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let lastmonth1=%sysfunc(month(%sysfunc(intnx(month,%sysfunc(today()),-1,s))));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;%put &amp;amp;&lt;SPAN&gt;lastmonth1;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 23 May 2018 16:13:29 GMT</pubDate>
    <dc:creator>mona4u</dc:creator>
    <dc:date>2018-05-23T16:13:29Z</dc:date>
    <item>
      <title>creating a macro of month names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-macro-of-month-names/m-p/464428#M118409</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create&amp;nbsp;macros that create month names&lt;/P&gt;&lt;P&gt;l need the macro to be able to create the exact&amp;nbsp;last month even though if it last year.&lt;/P&gt;&lt;P&gt;last time I created this macro to&amp;nbsp;create last month&amp;nbsp;# by the macro below&amp;nbsp; but I also need the month name too&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let lastmonth1=%sysfunc(month(%sysfunc(intnx(month,%sysfunc(today()),-1,s))));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;%put &amp;amp;&lt;SPAN&gt;lastmonth1;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 16:13:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-macro-of-month-names/m-p/464428#M118409</guid>
      <dc:creator>mona4u</dc:creator>
      <dc:date>2018-05-23T16:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: creating a macro of month names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-macro-of-month-names/m-p/464433#M118411</link>
      <description>&lt;P&gt;Use the MONNAME. format in the SYSFUNC() as the second parameter. See the doucmentstion for INTNX and SYSFUNC so you can see how to use it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134228"&gt;@mona4u&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to create&amp;nbsp;macros that create month names&lt;/P&gt;
&lt;P&gt;l need the macro to be able to create the exact&amp;nbsp;last month even though if it last year.&lt;/P&gt;
&lt;P&gt;last time I created this macro to&amp;nbsp;create last month&amp;nbsp;# by the macro below&amp;nbsp; but I also need the month name too&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let lastmonth1=%sysfunc(month(%sysfunc(intnx(month,%sysfunc(today()),-1,s))));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;%put &amp;amp;&lt;SPAN&gt;lastmonth1;&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 16:16:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-macro-of-month-names/m-p/464433#M118411</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-23T16:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: creating a macro of month names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-macro-of-month-names/m-p/464435#M118412</link>
      <description>&lt;P&gt;Use the WORDDAT format and parse out the name of the month.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let lastmonth1=%scan(%sysfunc(intnx(month,%sysfunc(today()),-1),worddat),1) ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 16:18:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-macro-of-month-names/m-p/464435#M118412</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-05-23T16:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: creating a macro of month names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-macro-of-month-names/m-p/464440#M118415</link>
      <description>&lt;P&gt;didn't work&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 16:23:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-macro-of-month-names/m-p/464440#M118415</guid>
      <dc:creator>mona4u</dc:creator>
      <dc:date>2018-05-23T16:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: creating a macro of month names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-macro-of-month-names/m-p/464611#M118470</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134228"&gt;@mona4u&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;didn't work&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Two problems. (1) the format name is really WORDDATE (not sure when SAS started creating format names with more than 7 characters?). (2) The WORDDATE (and also the MONNAME) format add leading spaces which seem to really confuse the %SCAN() function when trying to process in single nested call.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So use %Qsysfunc() instead to quote the comma and leading spaces.&amp;nbsp; Then the %SCAN() function works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let lastmonth=%scan(%qsysfunc(intnx(month,&amp;amp;today,-1),worddate),1);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 01:02:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-macro-of-month-names/m-p/464611#M118470</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-05-24T01:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: creating a macro of month names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-macro-of-month-names/m-p/464795#M118526</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134228"&gt;@mona4u&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;didn't work&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Two problems. (1) the format name is really WORDDATE (not sure when SAS started creating format names with more than 7 characters?). (2) The WORDDATE (and also the MONNAME) format add leading spaces which seem to really confuse the %SCAN() function when trying to process in single nested call.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So use %Qsysfunc() instead to quote the comma and leading spaces.&amp;nbsp; Then the %SCAN() function works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let lastmonth=%scan(%qsysfunc(intnx(month,&amp;amp;today,-1),worddate),1);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;this is what I tried and it works&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%let lastmonthn1=%sysfunc(intnx(month,%sysfunc(today()),-1),MONNAME.);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 15:03:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-macro-of-month-names/m-p/464795#M118526</guid>
      <dc:creator>mona4u</dc:creator>
      <dc:date>2018-05-24T15:03:07Z</dc:date>
    </item>
  </channel>
</rss>

