<?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: Convert month number to name in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289931#M59692</link>
    <description>&lt;P&gt;You can try using format monname3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
format a monname3.;
a=today();
put a=;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 06 Aug 2016 04:46:20 GMT</pubDate>
    <dc:creator>RahulG</dc:creator>
    <dc:date>2016-08-06T04:46:20Z</dc:date>
    <item>
      <title>Convert month number to name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289928#M59691</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm tyring to conver month number (e.g. 1,2,3) to name (e.g. JAN, FEB, MAR) in a field "Month" which is character field.&lt;/P&gt;&lt;P&gt;I tried below code;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc Format;&lt;/P&gt;&lt;P&gt;&amp;nbsp;INVALUE Month '1'='JAN', '2'='FEB','3'='MAR',&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it got errored out and error says that 'JAN' was not acceptable format.&amp;nbsp; I'm not sure what that means....&lt;/P&gt;&lt;P&gt;Does anyone how to fix this or know a batter to do?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;SKP&lt;/P&gt;</description>
      <pubDate>Sat, 06 Aug 2016 04:16:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289928#M59691</guid>
      <dc:creator>SKP</dc:creator>
      <dc:date>2016-08-06T04:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: Convert month number to name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289931#M59692</link>
      <description>&lt;P&gt;You can try using format monname3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
format a monname3.;
a=today();
put a=;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Aug 2016 04:46:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289931#M59692</guid>
      <dc:creator>RahulG</dc:creator>
      <dc:date>2016-08-06T04:46:20Z</dc:date>
    </item>
    <item>
      <title>Re: Convert month number to name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289932#M59693</link>
      <description>&lt;P&gt;There's no commas between the list of values. I also wouldn't recommend using the name month as its a function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you&amp;nbsp;convert it to a SAS date you can use MONNAME format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc format;
InValue $ monthFmt
'1' = 'Jan'
'2' = 'Feb'
...
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps if you explain how you plan to use it we can suggest more efficient methods.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Aug 2016 04:50:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289932#M59693</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-06T04:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: Convert month number to name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289935#M59694</link>
      <description>&lt;P&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;It did not work.&lt;/P&gt;&lt;P&gt;Where do you specify the dataset name?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I changed the field to "purchase_month", and had below.&lt;/P&gt;&lt;P&gt;Proc Format;&lt;/P&gt;&lt;P&gt;InValue $ purchase_monthFmt&lt;/P&gt;&lt;P&gt;'1' = 'JAN'&lt;/P&gt;&lt;P&gt;'2' = 'FEB'&lt;/P&gt;&lt;P&gt;'3' = 'MAR';&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did i have anything incorrect?&lt;/P&gt;</description>
      <pubDate>Sat, 06 Aug 2016 05:09:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289935#M59694</guid>
      <dc:creator>SKP</dc:creator>
      <dc:date>2016-08-06T05:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: Convert month number to name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289936#M59695</link>
      <description>&lt;P&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;I tried below and it returned as 'AUG' only.&amp;nbsp; I guess that's today's month....&lt;/P&gt;&lt;P&gt;Can you let me know where I can specify the dataset and field name?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Aug 2016 05:11:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289936#M59695</guid>
      <dc:creator>SKP</dc:creator>
      <dc:date>2016-08-06T05:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: Convert month number to name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289938#M59696</link>
      <description>&lt;P&gt;The format is MONNAME. Apply it the same way you were planning to use your custom format. It will only work of you have a full SAS date, numeric with a date format not a character or number 1/2/3.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Aug 2016 05:15:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289938#M59696</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-06T05:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: Convert month number to name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289941#M59697</link>
      <description>&lt;P&gt;Thank you for your reply.&amp;nbsp; I understand that I should have SAS date field to use the MONNAME function, but still couldn't get what I need.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me clarify what I'm doing again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In a data set "test", I have a date filed "purchase_date"&amp;nbsp;which has date&amp;nbsp;in MM/DD/YYYY format.&amp;nbsp; I wanted to add new field "purchase_month" in month name format (JAN, FEB etc) &amp;nbsp;based on "purchase_date".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now, I did not know MONNAME function, thus I pulled month as numeric&amp;nbsp;from "purchase_date" and tried to conver it to name.&amp;nbsp; But it sounds I should be able to pull month name (JAN, FEB) from "purchase_date".&lt;/P&gt;&lt;P&gt;Can you please let me know once again how I can do that with MONNAME function?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Aug 2016 05:57:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289941#M59697</guid>
      <dc:creator>SKP</dc:creator>
      <dc:date>2016-08-06T05:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Convert month number to name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289942#M59698</link>
      <description>&lt;P&gt;You are using Invalue keyword that will create informat.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I understand with your question that you want to convert 1 to Jan which can be done using format. &amp;nbsp;Be sure what do you want Format or Informat.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another point is you are considering 1 as character&amp;nbsp;in your code. Ensure that your input varaible where you are applying format is charcter type&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc Format;
Value $ purchase_monthFmt
'1' = 'JAN'
'2' = 'FEB'
'3' = 'MAR';
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 06 Aug 2016 05:58:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289942#M59698</guid>
      <dc:creator>RahulG</dc:creator>
      <dc:date>2016-08-06T05:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: Convert month number to name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289943#M59699</link>
      <description>&lt;P&gt;Since you want a new variable, create a new variable identical to the date and apply format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data Step&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Month = purchase_date;&lt;/P&gt;
&lt;P&gt;format month MONNAME.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SQL&lt;/P&gt;
&lt;P&gt;purchase_date as month format=MONNAME.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or convert to character month.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Month=put(purchase_date, monname3.);&lt;/P&gt;</description>
      <pubDate>Sat, 06 Aug 2016 06:07:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289943#M59699</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-06T06:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: Convert month number to name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289946#M59700</link>
      <description>&lt;P&gt;It seems it ran but nothing returned.&lt;/P&gt;&lt;P&gt;In Log Summary, it says Format $PURCHASE_MONTH has been output.&lt;/P&gt;&lt;P&gt;But I would like to overwite it in the same dataset in purchase_month filed where I have 1,2,3 etc.&lt;/P&gt;&lt;P&gt;Is there other code I need to have?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Aug 2016 06:12:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289946#M59700</guid>
      <dc:creator>SKP</dc:creator>
      <dc:date>2016-08-06T06:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: Convert month number to name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289948#M59701</link>
      <description>&lt;P&gt;I think I'm getting, but it's not quit working yet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried your 1st code as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data newdataset;&lt;/P&gt;&lt;P&gt;&amp;nbsp;purchse_month=purchse_date&lt;/P&gt;&lt;P&gt;format purchse_month MONNAME3.;&lt;/P&gt;&lt;P&gt;set olddataset;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, I have . in the 1st cell and everything god shifted down by 1 row.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you&amp;nbsp;know why it got shifted?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Aug 2016 06:26:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289948#M59701</guid>
      <dc:creator>SKP</dc:creator>
      <dc:date>2016-08-06T06:26:56Z</dc:date>
    </item>
    <item>
      <title>Re: Convert month number to name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289949#M59702</link>
      <description>&lt;P&gt;Put SET statement before you try to use the variables &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your trying to to use it before it exists.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Aug 2016 06:33:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289949#M59702</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-06T06:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: Convert month number to name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289953#M59703</link>
      <description>&lt;P&gt;It worked!!!!!!&lt;/P&gt;&lt;P&gt;Thank you very much for your help!!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And thank you for teaching me all other codes, as well.&amp;nbsp; I haven't tested all those yet, but will test them later to learn new codes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SKP&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Aug 2016 06:44:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Convert-month-number-to-name/m-p/289953#M59703</guid>
      <dc:creator>SKP</dc:creator>
      <dc:date>2016-08-06T06:44:39Z</dc:date>
    </item>
  </channel>
</rss>

