<?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 month to number from 1 to 12 in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/converting-month-to-number-from-1-to-12/m-p/492109#M31719</link>
    <description>&lt;P&gt;You aren’t reading the date as a SAS date, I’m guessing you have errors in the code shown as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Informat date anydtdte.;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add the line above BEFORE your input statement.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Sep 2018 19:59:39 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-09-03T19:59:39Z</dc:date>
    <item>
      <title>converting month to number from 1 to 12</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/converting-month-to-number-from-1-to-12/m-p/492077#M31712</link>
      <description>&lt;P&gt;Hi everyone,&lt;BR /&gt;I'm pretty new in using SAS. I am trying to write a code to show my month variable which is shown like JAN2018 FEB2018 MAR2018&lt;/P&gt;&lt;P&gt;APR2018&amp;nbsp; MAY2018 JUN2018 AUG2018 SEP2017 OCT2017 NOV2017 DEC2017..&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;What I am trying to do is I want show JAN2018= '1'&amp;nbsp; &amp;nbsp;FEB2018='2' MAR2018='3'&amp;nbsp; .......&amp;nbsp; and so on..&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;my data name is csh&lt;/P&gt;&lt;P&gt;my variable is month in date not string or num..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you help me how can I convert the month variable to numbers from 1 to 12?&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;Suna Morkoc&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 16:58:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/converting-month-to-number-from-1-to-12/m-p/492077#M31712</guid>
      <dc:creator>smorkoc</dc:creator>
      <dc:date>2018-09-03T16:58:36Z</dc:date>
    </item>
    <item>
      <title>Re: converting month to number from 1 to 12</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/converting-month-to-number-from-1-to-12/m-p/492079#M31713</link>
      <description>&lt;P&gt;If MONTH is an actual date value, but it has the MONYY7. format attached then just use the MONTH() function to find the month number in the year.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;monthnum = month(MONTH);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If MONTH is character then why not just convert it to a date first and then apply the function?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;monthnum=month(input('01'||month,date9.));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 17:32:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/converting-month-to-number-from-1-to-12/m-p/492079#M31713</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-09-03T17:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: converting month to number from 1 to 12</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/converting-month-to-number-from-1-to-12/m-p/492083#M31714</link>
      <description>&lt;P&gt;Do you want a new variable?&lt;/P&gt;
&lt;P&gt;In SAS you can either create a new variable or use it as shown and grouped as needed in summaries.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/123873"&gt;@smorkoc&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi everyone,&lt;BR /&gt;I'm pretty new in using SAS. I am trying to write a code to show my month variable which is shown like JAN2018 FEB2018 MAR2018&lt;/P&gt;
&lt;P&gt;APR2018&amp;nbsp; MAY2018 JUN2018 AUG2018 SEP2017 OCT2017 NOV2017 DEC2017..&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;What I am trying to do is I want show JAN2018= '1'&amp;nbsp; &amp;nbsp;FEB2018='2' MAR2018='3'&amp;nbsp; .......&amp;nbsp; and so on..&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;my data name is csh&lt;/P&gt;
&lt;P&gt;my variable is month in date not string or num..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you help me how can I convert the month variable to numbers from 1 to 12?&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;Suna Morkoc&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 18:18:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/converting-month-to-number-from-1-to-12/m-p/492083#M31714</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-03T18:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: converting month to number from 1 to 12</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/converting-month-to-number-from-1-to-12/m-p/492084#M31715</link>
      <description>&lt;P&gt;Thanks for your help. Should I use format statement then?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 18:24:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/converting-month-to-number-from-1-to-12/m-p/492084#M31715</guid>
      <dc:creator>smorkoc</dc:creator>
      <dc:date>2018-09-03T18:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: converting month to number from 1 to 12</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/converting-month-to-number-from-1-to-12/m-p/492090#M31716</link>
      <description>&lt;P&gt;I thought it would be much better to create a new variable because once I'm done with converting I need to group them as season like '12' '2' '3' = winter , '4' '5' '6' =spring etc..&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 18:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/converting-month-to-number-from-1-to-12/m-p/492090#M31716</guid>
      <dc:creator>smorkoc</dc:creator>
      <dc:date>2018-09-03T18:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: converting month to number from 1 to 12</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/converting-month-to-number-from-1-to-12/m-p/492103#M31717</link>
      <description>&lt;P&gt;here is the code I used but it did not work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data csh;&lt;BR /&gt;input month;&lt;BR /&gt;monthnum = month(MONTH);&lt;BR /&gt;cards;&lt;BR /&gt;Jan2018&lt;BR /&gt;Feb2018&lt;BR /&gt;Mar2018&lt;BR /&gt;Apr2018&lt;BR /&gt;May2018&lt;BR /&gt;Jun2018&lt;BR /&gt;Jul2018&lt;BR /&gt;Aug2018&lt;BR /&gt;Sep2017&lt;BR /&gt;Oct2017&lt;BR /&gt;Nov2017&lt;BR /&gt;Dec2017&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output is like&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Month&amp;nbsp; &amp;nbsp;Monthnum&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;5&amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;6&amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;7&amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;8&amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;9&amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;10&amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;11&amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;12&amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 19:07:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/converting-month-to-number-from-1-to-12/m-p/492103#M31717</guid>
      <dc:creator>smorkoc</dc:creator>
      <dc:date>2018-09-03T19:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: converting month to number from 1 to 12</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/converting-month-to-number-from-1-to-12/m-p/492104#M31718</link>
      <description>&lt;P&gt;And when I just tried this code ;&lt;/P&gt;&lt;P&gt;data csh1;&lt;BR /&gt;set csh;&lt;BR /&gt;format Month monthnum;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think this is right one but the output shows&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;21063&lt;BR /&gt;21063&lt;BR /&gt;21063&lt;BR /&gt;21093&lt;BR /&gt;21093&lt;BR /&gt;21093&lt;BR /&gt;21124&lt;BR /&gt;21124&lt;BR /&gt;21124&lt;BR /&gt;21154&lt;BR /&gt;21154&lt;BR /&gt;21154&lt;BR /&gt;21185&lt;BR /&gt;21185&lt;BR /&gt;21185&lt;BR /&gt;21216&lt;BR /&gt;21216&lt;BR /&gt;21216&lt;BR /&gt;21244&lt;BR /&gt;21244&lt;BR /&gt;21244&lt;BR /&gt;21275&lt;BR /&gt;21275&lt;BR /&gt;21275&lt;BR /&gt;21305&lt;BR /&gt;21305&lt;BR /&gt;21305&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;so on.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I guess it is because SAS takes the first date as 1960 or sth.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 19:11:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/converting-month-to-number-from-1-to-12/m-p/492104#M31718</guid>
      <dc:creator>smorkoc</dc:creator>
      <dc:date>2018-09-03T19:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: converting month to number from 1 to 12</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/converting-month-to-number-from-1-to-12/m-p/492109#M31719</link>
      <description>&lt;P&gt;You aren’t reading the date as a SAS date, I’m guessing you have errors in the code shown as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Informat date anydtdte.;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add the line above BEFORE your input statement.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 19:59:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/converting-month-to-number-from-1-to-12/m-p/492109#M31719</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-03T19:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: converting month to number from 1 to 12</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/converting-month-to-number-from-1-to-12/m-p/492111#M31720</link>
      <description>&lt;P&gt;You've gotten the right advice.&amp;nbsp; You need to put it together in the proper places.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You already have a data set CSH.&amp;nbsp; It already contains valid SAS dates in a variable named MONTH.&amp;nbsp; You don't need to input anything.&amp;nbsp; You just need to read the existing SAS data set:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set csh;&lt;/P&gt;
&lt;P&gt;monthnum = month(month);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 20:15:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/converting-month-to-number-from-1-to-12/m-p/492111#M31720</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-09-03T20:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: converting month to number from 1 to 12</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/converting-month-to-number-from-1-to-12/m-p/492112#M31721</link>
      <description>&lt;P&gt;Thank you so much! It worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 20:23:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/converting-month-to-number-from-1-to-12/m-p/492112#M31721</guid>
      <dc:creator>smorkoc</dc:creator>
      <dc:date>2018-09-03T20:23:03Z</dc:date>
    </item>
  </channel>
</rss>

