<?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: convert month in num in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/convert-month-in-num/m-p/87137#M9193</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks for answer...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is there any format through which i can convert it like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;x= input('jan',monname3.);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;plz guide me..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 26 Jan 2013 18:14:32 GMT</pubDate>
    <dc:creator>Aman4SAS</dc:creator>
    <dc:date>2013-01-26T18:14:32Z</dc:date>
    <item>
      <title>convert month in num</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/convert-month-in-num/m-p/87135#M9191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;input month $ sale;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;jan 2000&lt;/P&gt;&lt;P&gt;feb 1400&lt;/P&gt;&lt;P&gt;mar 2300&lt;/P&gt;&lt;P&gt;apr 3400&lt;/P&gt;&lt;P&gt;may 2700&lt;/P&gt;&lt;P&gt;jun 3200&lt;/P&gt;&lt;P&gt;july 800&lt;/P&gt;&lt;P&gt;aug 2900&lt;/P&gt;&lt;P&gt;sep 1700&lt;/P&gt;&lt;P&gt;oct 2100&lt;/P&gt;&lt;P&gt;nov 2600&lt;/P&gt;&lt;P&gt;dec 3200&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i m looking to convert month in num as 1 2 3 ,&lt;/P&gt;&lt;P&gt;for that i m tring it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test1;&lt;/P&gt;&lt;P&gt;set test;&lt;/P&gt;&lt;P&gt;mon_num=input(month,monname3.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but its showing error. i need to short data by month. can we do it in short or sud i use if condition on each month????&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;desired output is&lt;/P&gt;&lt;P&gt;month sale&lt;/P&gt;&lt;P&gt;1 2000&lt;/P&gt;&lt;P&gt;2 1400&lt;/P&gt;&lt;P&gt;3 2300&lt;/P&gt;&lt;P&gt;4 3400&lt;/P&gt;&lt;P&gt;.......&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 Jan 2013 16:42:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/convert-month-in-num/m-p/87135#M9191</guid>
      <dc:creator>Aman4SAS</dc:creator>
      <dc:date>2013-01-26T16:42:20Z</dc:date>
    </item>
    <item>
      <title>Re: convert month in num</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/convert-month-in-num/m-p/87136#M9192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;input month $ sale;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;jan 2000&lt;/P&gt;&lt;P&gt;feb 1400&lt;/P&gt;&lt;P&gt;mar 2300&lt;/P&gt;&lt;P&gt;apr 3400&lt;/P&gt;&lt;P&gt;may 2700&lt;/P&gt;&lt;P&gt;jun 3200&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;jul&lt;/SPAN&gt; 800&lt;/P&gt;&lt;P&gt;aug 2900&lt;/P&gt;&lt;P&gt;sep 1700&lt;/P&gt;&lt;P&gt;oct 2100&lt;/P&gt;&lt;P&gt;nov 2600&lt;/P&gt;&lt;P&gt;dec 3200&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set test;&lt;/P&gt;&lt;P&gt;num_month=month(input(cats('01',month,'2013'),date9.));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 Jan 2013 18:06:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/convert-month-in-num/m-p/87136#M9192</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2013-01-26T18:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: convert month in num</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/convert-month-in-num/m-p/87137#M9193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks for answer...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is there any format through which i can convert it like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;x= input('jan',monname3.);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;plz guide me..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 Jan 2013 18:14:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/convert-month-in-num/m-p/87137#M9193</guid>
      <dc:creator>Aman4SAS</dc:creator>
      <dc:date>2013-01-26T18:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: convert month in num</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/convert-month-in-num/m-p/87138#M9194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;make your own!&lt;/P&gt;&lt;P&gt;see PROC FORMAT&lt;/P&gt;&lt;P&gt;and its INVALUE statement&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 Jan 2013 19:21:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/convert-month-in-num/m-p/87138#M9194</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2013-01-26T19:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: convert month in num</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/convert-month-in-num/m-p/87139#M9195</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp; To work with SAS date variables, remember that a SAS date variable is a number that represents the number of days since January 1, 1960. When you use the INPUT function, you are converting a character string or character variable into a SAS numeric variable. When you do the conversion, you must use an INFORMAT to convert your character variable to a number. MONNAME is a FORMAT -- it is used to display a SAS date variable (such as in PROC PRINT, PROC REPORT or PROC TABULATE report) as a 3 character month name. So it would not be appropriate to use MONNAME with an INPUT statement. In fact, you should have gotten this error message in your SAS log:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ERROR 48-59: The informat MONNAME was not found or could not be loaded.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; So, the correct thing to do was to turn your character string into a SAS date variable, so you could use the MONTH function, as Linlin demonstrated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; When you ask whether there is any FORMAT you can use, with an INPUT function, the answer is NO. You have to use an INFORMAT with the INPUT function. But the larger issue is that 'Jan" and "Feb" are character strings. They are not date values, in SAS terms. Yes, they are the names of months, but the name of the month is not the same thing as a SAS date value. That's why Linlin's solution took the month string and used it to make a real SAS date value (number of days since Jan 1, 1960). Then the month function returned the month number, which is&amp;nbsp; what you said you wanted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Perhaps this Tech Support note will give you a direction. (&lt;A href="http://support.sas.com/kb/24/651.html" title="http://support.sas.com/kb/24/651.html"&gt;24651 - Generate the month name from a numeric value&lt;/A&gt;) The note doesn't show exactly what you want to do, but the Sample 2 program does show how to write a format to turn a number into a month name. The reverse is also possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cynthia&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 Jan 2013 19:55:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/convert-month-in-num/m-p/87139#M9195</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2013-01-26T19:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: convert month in num</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/convert-month-in-num/m-p/87140#M9196</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;and to follow what I said earlier and Cynthia has pointed you at, the SAS System provides the functionality you are asking about - you just have to go use it&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data ;&lt;/P&gt;&lt;P&gt;input mth_str M3N3. @1 buffr :$20.&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;put mth_str= buffr= ;&lt;/P&gt;&lt;P&gt;list;cards;&lt;/P&gt;&lt;P&gt;Jan&lt;/P&gt;&lt;P&gt;january&lt;/P&gt;&lt;P&gt;June&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;will demo the results you want only if you first create that informat .....&lt;/P&gt;&lt;P&gt;perhaps something like&lt;/P&gt;&lt;P&gt;proc format ;&lt;/P&gt;&lt;P&gt;invalue m3n (upcase) JAN = 1 FEB=2 MAR=3 APR=4 MAY=5&lt;/P&gt;&lt;P&gt;JUN=6&amp;nbsp; OTHER=_ERROR_ ;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 Jan 2013 23:39:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/convert-month-in-num/m-p/87140#M9196</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2013-01-26T23:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: convert month in num</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/convert-month-in-num/m-p/265622#M15684</link>
      <description>&lt;P&gt;Hi Cynthia,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to convert a month varibale which is in String/Character format eg(Feb, Mar etc) to Date format of same eg(Feb, Mar)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am also trying to convert a year Variable (string) to Date format.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: Year and Month are two different variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I kindly request you to help me with this with a sample expample so that i can follow the same code and try it with my case&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; regards,&lt;/P&gt;&lt;P&gt;Karthik&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2016 11:29:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/convert-month-in-num/m-p/265622#M15684</guid>
      <dc:creator>Karthikk</dc:creator>
      <dc:date>2016-04-22T11:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: convert month in num</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/convert-month-in-num/m-p/266151#M15709</link>
      <description>Hi: I am not sure what you are asking and how it is relevant to the previous posting. That older posting was from 2013. If you are asking how to convert the string '2016' to the numeric value 2016, that would be done with an INPUT function. And, if you want to convert a string of 'Jan' to the number 1 and the string 'Feb' to the number 2, then that would also use an INPUT function.&lt;BR /&gt;&lt;BR /&gt;I would suggest that you make a new post instead of re-activating a previously solved post and show a sample of your data and the code that you've tried, so that people know what the new question is. &lt;BR /&gt;&lt;BR /&gt;cynthia</description>
      <pubDate>Mon, 25 Apr 2016 18:26:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/convert-month-in-num/m-p/266151#M15709</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2016-04-25T18:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: convert month in num</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/convert-month-in-num/m-p/266257#M15712</link>
      <description>Ohhh I am sorry I did not know that I have to post a new question. Anyways thank you for replying.</description>
      <pubDate>Tue, 26 Apr 2016 02:04:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/convert-month-in-num/m-p/266257#M15712</guid>
      <dc:creator>Karthikk</dc:creator>
      <dc:date>2016-04-26T02:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: convert month in num</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/convert-month-in-num/m-p/266485#M15729</link>
      <description>Hi:&lt;BR /&gt;  Generally, when a previous posting has already been solved and/or is old (more than a few months), it is better to start a new post instead of "waking up" an older post. No worries, if someone doesn't scroll all the way to the bottom, they might miss your current post.&lt;BR /&gt;&lt;BR /&gt;  It's just better all around if you have a related question to start a new post and then, you can put a link to the older post in your new posting and say something like, "I saw this previous post here: xxxxx, but it didn't seem to address my question."&lt;BR /&gt;&lt;BR /&gt;cynthia</description>
      <pubDate>Tue, 26 Apr 2016 18:33:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/convert-month-in-num/m-p/266485#M15729</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2016-04-26T18:33:45Z</dc:date>
    </item>
  </channel>
</rss>

