<?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 and year from datetime variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-Month-and-year-from-datetime-variable/m-p/806604#M317833</link>
    <description>Thanks.  That should get me where I want to go.</description>
    <pubDate>Thu, 07 Apr 2022 18:33:19 GMT</pubDate>
    <dc:creator>RandoDando</dc:creator>
    <dc:date>2022-04-07T18:33:19Z</dc:date>
    <item>
      <title>Extract Month and year from datetime variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-Month-and-year-from-datetime-variable/m-p/806601#M317830</link>
      <description>&lt;P&gt;Let me start by saying the subject of the topic makes this seem simpler than it is.&amp;nbsp; I know how to get a month and year from a date already.&amp;nbsp; However, the month in this case appears as a number and I want the 3 letter abbreviation.&amp;nbsp; I tried using the monyy7. format, but using a format only changes the displayed value.&amp;nbsp; When I try to create another table in a PROC SQL statement to group by the new dates (MONTHYEAR) I get more than 1 row per month because the actual day is being read "behind the scenes".&amp;nbsp;&amp;nbsp; How can I efficiently convert a date into the APR2022 value without using a format statement?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 18:14:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-Month-and-year-from-datetime-variable/m-p/806601#M317830</guid>
      <dc:creator>RandoDando</dc:creator>
      <dc:date>2022-04-07T18:14:06Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Month and year from datetime variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-Month-and-year-from-datetime-variable/m-p/806602#M317831</link>
      <description>&lt;P&gt;So you want a new variable that contains the three letter month?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;month_abbreviation = put(datevariable,monname3.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While there are certainly good reasons to create this new variable, I point out that it will not sort in any meaningful order, this new variable will sort alphabetically so the first month of the year is APR and the second month of the year is AUG, and that's not usually what people want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want the 3 letter abbreviation to appear and still have the months sort properly, then you would apply the format MONNAME3. to your date variable.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 18:34:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-Month-and-year-from-datetime-variable/m-p/806602#M317831</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-07T18:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Month and year from datetime variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-Month-and-year-from-datetime-variable/m-p/806604#M317833</link>
      <description>Thanks.  That should get me where I want to go.</description>
      <pubDate>Thu, 07 Apr 2022 18:33:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-Month-and-year-from-datetime-variable/m-p/806604#M317833</guid>
      <dc:creator>RandoDando</dc:creator>
      <dc:date>2022-04-07T18:33:19Z</dc:date>
    </item>
  </channel>
</rss>

