<?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: converting months to numbers in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/converting-months-to-numbers/m-p/689231#M209505</link>
    <description>&lt;P&gt;Don't create a new column. Just assign the YYMMN6. format to this variable.&lt;/P&gt;</description>
    <pubDate>Tue, 06 Oct 2020 14:49:48 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-10-06T14:49:48Z</dc:date>
    <item>
      <title>converting months to numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-months-to-numbers/m-p/689229#M209504</link>
      <description>&lt;P&gt;I have a dataset which has a column named Month in yymmdd10. format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I use the information in the Month column to create a new column called&lt;/P&gt;
&lt;P&gt;Month2 whereby the data is in the following format - 200901, 200902, ...200912:&lt;/P&gt;
&lt;P&gt;for e.g.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;200901 for&amp;nbsp;2009-01-01&lt;/P&gt;
&lt;P&gt;201212 for 2012-01-01&lt;/P&gt;
&lt;P&gt;..etc&lt;/P&gt;
&lt;P&gt;I would like Month2 to be just numbers.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Oct 2020 14:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-months-to-numbers/m-p/689229#M209504</guid>
      <dc:creator>ubshams</dc:creator>
      <dc:date>2020-10-06T14:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: converting months to numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-months-to-numbers/m-p/689231#M209505</link>
      <description>&lt;P&gt;Don't create a new column. Just assign the YYMMN6. format to this variable.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Oct 2020 14:49:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-months-to-numbers/m-p/689231#M209505</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-10-06T14:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: converting months to numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-months-to-numbers/m-p/689232#M209506</link>
      <description>&lt;P&gt;Thanks but I actually need the new column to be in a numbers format to match with&amp;nbsp;&lt;/P&gt;
&lt;P&gt;our internal database. So they need to be in the 200901, 200902, etc format.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Oct 2020 14:55:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-months-to-numbers/m-p/689232#M209506</guid>
      <dc:creator>ubshams</dc:creator>
      <dc:date>2020-10-06T14:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: converting months to numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-months-to-numbers/m-p/689238#M209509</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/185449"&gt;@ubshams&lt;/a&gt;&amp;nbsp; Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input month :yymmdd10.;
    format month yymmdd10.;
    datalines;
    2009-01-01
    2012-01-01
    2020-10-06
    ;
run;

data want;
    set have;
    month2 = input(put(month, yymmn6.), 6.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Oct 2020 15:09:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-months-to-numbers/m-p/689238#M209509</guid>
      <dc:creator>mklangley</dc:creator>
      <dc:date>2020-10-06T15:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: converting months to numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-months-to-numbers/m-p/689239#M209510</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;New_col=input(put(date,yymmn6. -l),6.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Oct 2020 15:10:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-months-to-numbers/m-p/689239#M209510</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-10-06T15:10:13Z</dc:date>
    </item>
    <item>
      <title>Re: converting months to numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-months-to-numbers/m-p/689250#M209515</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;month_number = year(date)*100 + month(date);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/185449"&gt;@ubshams&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a dataset which has a column named Month in yymmdd10. format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I use the information in the Month column to create a new column called&lt;/P&gt;
&lt;P&gt;Month2 whereby the data is in the following format - 200901, 200902, ...200912:&lt;/P&gt;
&lt;P&gt;for e.g.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;200901 for&amp;nbsp;2009-01-01&lt;/P&gt;
&lt;P&gt;201212 for 2012-01-01&lt;/P&gt;
&lt;P&gt;..etc&lt;/P&gt;
&lt;P&gt;I would like Month2 to be just numbers.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&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>Tue, 06 Oct 2020 15:41:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-months-to-numbers/m-p/689250#M209515</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-10-06T15:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: converting months to numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-months-to-numbers/m-p/689257#M209516</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/185449"&gt;@ubshams&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks but I actually need the new column to be in a numbers format to match with&amp;nbsp;&lt;/P&gt;
&lt;P&gt;our internal database. So they need to be in the 200901, 200902, etc format.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Actually, no you don't. When you need numbers to be 200901, 200902, etc, you use the YYMMN6. format. When you want them to be 2009-01-01 you use the YYMMDD10. format. And so on. This leaves the value as a true SAS date value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The solution you marked correct does not result in SAS date values, it results in integers where you have to provide the logic&amp;nbsp; to find what month comes before 201001 and how many months are in between 200908 and 201006, and so on. Many drawbacks.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Oct 2020 15:55:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-months-to-numbers/m-p/689257#M209516</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-10-06T15:55:32Z</dc:date>
    </item>
  </channel>
</rss>

