<?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: month change in numaric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/month-change-in-numaric/m-p/330781#M74281</link>
    <description>&lt;P&gt;You will want to try the datastep I posted which does exactly what you ask for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a note, you are getting data from a database in date parts yes. &amp;nbsp;If so then I recommend you get to one of the CDISC models, i.e. have a character date field which is the various parts of the date in ISO format, and also if you doing an analysis model then have a numeric date variable as well - this gives you the best of both worlds.&lt;/P&gt;</description>
    <pubDate>Wed, 08 Feb 2017 10:53:44 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-02-08T10:53:44Z</dc:date>
    <item>
      <title>month change in numaric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/month-change-in-numaric/m-p/330774#M74276</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;I'm tried &amp;nbsp;to convert month (e.g. JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC) this one change's to numaric month 01,02,03....etc please tell me how to change in easy&amp;nbsp;method .&amp;nbsp; &amp;nbsp;i tried this one below. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if Month="JAN" then m="01";&lt;BR /&gt;if Month="FEB" then m="02";&lt;BR /&gt;if Month="MAR" then m="03";&lt;BR /&gt;if Month="APR" then m="04";&lt;BR /&gt;if Month="MAY" then m="05";&lt;BR /&gt;if Month="JUN" then m="06";&lt;BR /&gt;if Month="JUL" then m="07";&lt;BR /&gt;if Month="AUG" then m="08";&lt;BR /&gt;if Month="SEP" then m="09";&lt;BR /&gt;if Month="OCT" then m="10";&lt;BR /&gt;if Month="NOV" then m="11";&lt;BR /&gt;if Month="DEC" then m="12";&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 10:33:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/month-change-in-numaric/m-p/330774#M74276</guid>
      <dc:creator>teja5959</dc:creator>
      <dc:date>2017-02-08T10:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: month change in numaric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/month-change-in-numaric/m-p/330777#M74278</link>
      <description>&lt;P&gt;Follow the guidance you will see at the bottom of where you post. &amp;nbsp;Post example test data in the form of a datastep. &amp;nbsp;This is critical for us to see as we don't know what you are working with. &amp;nbsp;For example, if you data is a numeric SAS date, you could simply use the month() function to extract month name. &amp;nbsp;This being know, if you have a character variable with month, then thinking logically you could append 01 and 2010 to that month, create a date variable and then extract using the month() function. &amp;nbsp;As I have no test data I am going to assume month variable is character:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  m=month(input(cats('01',month,'2010'),date9.));
run;&lt;/PRE&gt;
&lt;P&gt;You could also create a format for it - though I personal avoid compiled anything as much as possible so would go with the above.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 10:39:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/month-change-in-numaric/m-p/330777#M74278</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-02-08T10:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: month change in numaric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/month-change-in-numaric/m-p/330779#M74280</link>
      <description>Thanks for quick reply!&lt;BR /&gt;&lt;BR /&gt;Am working with clinical data, char_variable have months name as "JAN"&lt;BR /&gt;etc.. i want to convert it to numeric version of months to other variable,&lt;BR /&gt;please let me know how it can be done in data step&lt;BR /&gt;&lt;BR /&gt;Thanks again!&lt;BR /&gt;Teja&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Wed, 08 Feb 2017 10:49:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/month-change-in-numaric/m-p/330779#M74280</guid>
      <dc:creator>teja5959</dc:creator>
      <dc:date>2017-02-08T10:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: month change in numaric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/month-change-in-numaric/m-p/330781#M74281</link>
      <description>&lt;P&gt;You will want to try the datastep I posted which does exactly what you ask for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a note, you are getting data from a database in date parts yes. &amp;nbsp;If so then I recommend you get to one of the CDISC models, i.e. have a character date field which is the various parts of the date in ISO format, and also if you doing an analysis model then have a numeric date variable as well - this gives you the best of both worlds.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 10:53:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/month-change-in-numaric/m-p/330781#M74281</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-02-08T10:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: month change in numaric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/month-change-in-numaric/m-p/330787#M74282</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;&amp;nbsp;code is the right answer to your question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want m to be a char variable instead, apply the put function to the result like below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  m=put(month(input(cats('01',month,'2010'),date9.)),z2.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Danile Santos&amp;nbsp;@ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 11:13:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/month-change-in-numaric/m-p/330787#M74282</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2017-02-08T11:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: month change in numaric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/month-change-in-numaric/m-p/330819#M74289</link>
      <description>&lt;P&gt;If I understand correctly, M is coming out as numeric when you would like it to be character. &amp;nbsp;If that is the problem, your code is correct as is. &amp;nbsp;The problem is that your data set already contains M and it is already defined as numeric. &amp;nbsp;You can change this by getting rid of the old M:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have (drop=M);&lt;/P&gt;
&lt;P&gt;* All your IF/THEN statements here;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 13:04:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/month-change-in-numaric/m-p/330819#M74289</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-02-08T13:04:21Z</dc:date>
    </item>
  </channel>
</rss>

