<?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: Extract Month (MMM) from Character Date String in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-Month-MMM-from-Character-Date-String/m-p/669212#M200723</link>
    <description>&lt;P&gt;&lt;STRONG&gt;If your problem is as described&lt;/STRONG&gt;, then this does work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assumptions:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Variable name is DeliveryDate&lt;/LI&gt;
&lt;LI&gt;Variable is character&lt;/LI&gt;
&lt;LI&gt;Variable is in the format mmddyy consistently.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;You can verify your assumptions by running a proc contents on your data set as well as a PROC FREQ on your delivery date column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="delete_monthname.JPG" style="width: 868px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47134iCB76EE4BABBFB7E1/image-size/large?v=v2&amp;amp;px=999" role="button" title="delete_monthname.JPG" alt="delete_monthname.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 14 Jul 2020 16:09:30 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-07-14T16:09:30Z</dc:date>
    <item>
      <title>Extract Month (MMM) from Character Date String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-Month-MMM-from-Character-Date-String/m-p/669185#M200709</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently working with a dataset that has deliverydate field as CHAR 10. I'd like to keep it as a character value, and was able to pull the month out of the string using the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DeliveryMonth= MONTH(input('DeliveryDate'n,MMDDYY10.));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DeliveryMonth is the column I'm creating, however the output is the # for the associated month. Example: 06/01/2020 in DeliveryDate is populating "6" in DeliveryMonth. Is there a way to have DeliveryMonth as "MMM" within this data step?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any and all advice would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Blake&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 15:06:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-Month-MMM-from-Character-Date-String/m-p/669185#M200709</guid>
      <dc:creator>bc123456</dc:creator>
      <dc:date>2020-07-14T15:06:18Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Month (MMM) from Character Date String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-Month-MMM-from-Character-Date-String/m-p/669189#M200712</link>
      <description>&lt;BR /&gt;deliveryMonth = put(input(deliveryDate, mmddyy10.), monname3.);&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Jul 2020 15:10:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-Month-MMM-from-Character-Date-String/m-p/669189#M200712</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-14T15:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Month (MMM) from Character Date String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-Month-MMM-from-Character-Date-String/m-p/669198#M200717</link>
      <description>When I try this, I end up with a single dot in each row.</description>
      <pubDate>Tue, 14 Jul 2020 15:27:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-Month-MMM-from-Character-Date-String/m-p/669198#M200717</guid>
      <dc:creator>bc123456</dc:creator>
      <dc:date>2020-07-14T15:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Month (MMM) from Character Date String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-Month-MMM-from-Character-Date-String/m-p/669200#M200718</link>
      <description>&lt;P&gt;To&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/333771"&gt;@bc123456&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/223296"&gt;@mklangley&lt;/a&gt;&amp;nbsp;: do not use the dreaded name literals, especially not when they're not necessary.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 15:28:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-Month-MMM-from-Character-Date-String/m-p/669200#M200718</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-14T15:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Month (MMM) from Character Date String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-Month-MMM-from-Character-Date-String/m-p/669212#M200723</link>
      <description>&lt;P&gt;&lt;STRONG&gt;If your problem is as described&lt;/STRONG&gt;, then this does work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assumptions:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Variable name is DeliveryDate&lt;/LI&gt;
&lt;LI&gt;Variable is character&lt;/LI&gt;
&lt;LI&gt;Variable is in the format mmddyy consistently.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;You can verify your assumptions by running a proc contents on your data set as well as a PROC FREQ on your delivery date column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="delete_monthname.JPG" style="width: 868px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47134iCB76EE4BABBFB7E1/image-size/large?v=v2&amp;amp;px=999" role="button" title="delete_monthname.JPG" alt="delete_monthname.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 16:09:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-Month-MMM-from-Character-Date-String/m-p/669212#M200723</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-14T16:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Month (MMM) from Character Date String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-Month-MMM-from-Character-Date-String/m-p/669232#M200731</link>
      <description>&lt;P&gt;This would happen if, in your many experiments, you already created a variable named DeliveryMonth as numeric.&amp;nbsp; You would have to get rid of it somehow, possibly:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set have (drop=DeliveryMonth);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Jul 2020 16:30:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-Month-MMM-from-Character-Date-String/m-p/669232#M200731</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-07-14T16:30:28Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Month (MMM) from Character Date String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-Month-MMM-from-Character-Date-String/m-p/669248#M200739</link>
      <description>The log would have a message about mismatched types wouldn't it?</description>
      <pubDate>Tue, 14 Jul 2020 17:20:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-Month-MMM-from-Character-Date-String/m-p/669248#M200739</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-14T17:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Month (MMM) from Character Date String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-Month-MMM-from-Character-Date-String/m-p/669255#M200741</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/333771"&gt;@bc123456&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;When I try this, I end up with a single dot in each row.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Show your entire data step code with notes from the log. Copy the text from the log including any messages. Paste on the forum into a code box opened using the the &amp;lt;/&amp;gt; icon to preserve formatting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use code structure like:&lt;/P&gt;
&lt;PRE&gt;Data test;
   set test;
   &amp;lt;testing code&amp;gt;
run;&lt;/PRE&gt;
&lt;P&gt;Then in one or more previous iterations of that data step you created DeliveryMonth as numeric and SAS won't let you put character values into numeric values. The above Data test; set test; is a very poor idea for new SAS coders to use because you completely rewrite your data every time. So logic errors can remove records or lose variables you did not intend. And a host of more subtle bad things can happen if you recode variable values back to the same variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if the you had initially created a date variable for keeping in your data you would likely almost certainly not need an additional variable but use the MONNAME format with a data value as needed in analysis, reports or graphs. One reason not to use character Month values is that they will not sort properly in reports or graphs. The year would start with April, then August and ends with November.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 18:14:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-Month-MMM-from-Character-Date-String/m-p/669255#M200741</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-07-14T18:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Month (MMM) from Character Date String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-Month-MMM-from-Character-Date-String/m-p/669307#M200763</link>
      <description>&lt;P&gt;There would be some messages ... character to numeric conversion, invalid data.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 21:10:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-Month-MMM-from-Character-Date-String/m-p/669307#M200763</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-07-14T21:10:28Z</dc:date>
    </item>
  </channel>
</rss>

