<?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: Month to Calendar Month in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Month-to-Calendar-Month/m-p/495197#M130651</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input month 2.;
cards;
1
2
3
4
10
11
12
;
run;

data want;
set have;
month2=put(intnx('month',mdy(mod(month+7,12)+1,1,2017),0,'e'),date9.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 13 Sep 2018 08:34:13 GMT</pubDate>
    <dc:creator>gamotte</dc:creator>
    <dc:date>2018-09-13T08:34:13Z</dc:date>
    <item>
      <title>Month to Calendar Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-to-Calendar-Month/m-p/495190#M130647</link>
      <description>Hi Community,&lt;BR /&gt;&lt;BR /&gt;I have had trouble converting month in numeric to calendar month.&lt;BR /&gt;&lt;BR /&gt;The month column in my data is numeric, it shows the name of the month in the output table however the format is numeric.&lt;BR /&gt;&lt;BR /&gt;My employer’s financial year runs from September to August so my data has 1 for September and 12 for August.&lt;BR /&gt;&lt;BR /&gt;I am trying to convert month 1 ( September) to 30Sep17 etc.&lt;BR /&gt;&lt;BR /&gt;How could I do that?&lt;BR /&gt;&lt;BR /&gt;I truly value your help.&lt;BR /&gt;&lt;BR /&gt;Magstar</description>
      <pubDate>Thu, 13 Sep 2018 08:12:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-to-Calendar-Month/m-p/495190#M130647</guid>
      <dc:creator>Timbim</dc:creator>
      <dc:date>2018-09-13T08:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: Month to Calendar Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-to-Calendar-Month/m-p/495194#M130649</link>
      <description>&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Please post test data in the form of a datastep!!&lt;/STRONG&gt;&lt;/U&gt;&amp;nbsp; And show what you want the output to look like.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest, as nothing really to work with, create format:&lt;/P&gt;
&lt;PRE&gt;proc format;
  value mt
    1="SEP"
     2="OCT"
...
run;
&lt;/PRE&gt;
&lt;P&gt;Then use that format:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  new_date=intnx('month',input(cats("01",put(month,mt.),"2017"),date9.),0,"e");
run;&lt;/PRE&gt;
&lt;P&gt;Note, I am having to use the intnx() to move the value to the end of the month as for some reason you seem to want this - 30 is not an available day in Febuary for instance.&amp;nbsp; I would default to 01.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 08:24:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-to-Calendar-Month/m-p/495194#M130649</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-13T08:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: Month to Calendar Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-to-Calendar-Month/m-p/495197#M130651</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input month 2.;
cards;
1
2
3
4
10
11
12
;
run;

data want;
set have;
month2=put(intnx('month',mdy(mod(month+7,12)+1,1,2017),0,'e'),date9.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Sep 2018 08:34:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-to-Calendar-Month/m-p/495197#M130651</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-09-13T08:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: Month to Calendar Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-to-Calendar-Month/m-p/495201#M130654</link>
      <description>&lt;P&gt;Nice, didn't think of modding it to go over the year end, hence why I went with the format.&amp;nbsp; Need another cup of tea.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 08:45:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-to-Calendar-Month/m-p/495201#M130654</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-13T08:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: Month to Calendar Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-to-Calendar-Month/m-p/497686#M132004</link>
      <description>&lt;P&gt;Hi Gamote,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please explain what your code is doing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; want&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;month2&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;put&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;intnx&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'month'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;mdy&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;mod&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;month&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;7&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;12&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2017&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'e'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;date9&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="token punctuation"&gt;I am only beginning to use SAS frequently now and have not used mdy or mod before&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Thanks kindly,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Magstar.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 05:26:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-to-Calendar-Month/m-p/497686#M132004</guid>
      <dc:creator>Timbim</dc:creator>
      <dc:date>2018-09-21T05:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Month to Calendar Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-to-Calendar-Month/m-p/497721#M132023</link>
      <description>&lt;P&gt;Sure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token function"&gt;mod&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;month&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;7&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;12&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; is the modulo function (equivalent to % operator in some other languages) and is used to get the right month number from your month variable (1:jan, 2:feb,...)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token function"&gt;mdy&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;...&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2017&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt; creates a date variable for the 1st of the selected month&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token function"&gt;intnx&lt;/SPAN&gt;('month',&lt;SPAN class="token string"&gt;...&lt;/SPAN&gt;,&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;,&lt;SPAN class="token string"&gt;'e'&lt;/SPAN&gt;) changes the date to the last day ('e' parameter) of the unchanged month ('month' and 0 parameters) &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 08:02:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-to-Calendar-Month/m-p/497721#M132023</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-09-21T08:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: Month to Calendar Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-to-Calendar-Month/m-p/505803#M135497</link>
      <description>&lt;P&gt;Got it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for explaining it so clearly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Magstart&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 00:07:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-to-Calendar-Month/m-p/505803#M135497</guid>
      <dc:creator>Timbim</dc:creator>
      <dc:date>2018-10-19T00:07:31Z</dc:date>
    </item>
  </channel>
</rss>

