<?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 of time in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/month-of-time/m-p/851595#M336603</link>
    <description>It helped a lot, thank you!</description>
    <pubDate>Fri, 30 Dec 2022 10:01:55 GMT</pubDate>
    <dc:creator>znhnm</dc:creator>
    <dc:date>2022-12-30T10:01:55Z</dc:date>
    <item>
      <title>month of time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/month-of-time/m-p/851571#M336588</link>
      <description>&lt;P&gt;I have a time type columnç One example record is:&amp;nbsp;&lt;SPAN&gt;03JUN22:00:00:00.&lt;BR /&gt;&lt;BR /&gt;How can I get the month part of it, JUN? Thank you!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 02:35:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/month-of-time/m-p/851571#M336588</guid>
      <dc:creator>znhnm</dc:creator>
      <dc:date>2022-12-30T02:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: month of time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/month-of-time/m-p/851572#M336589</link>
      <description>This will get you the month as a number from 1 to 12:&lt;BR /&gt;&lt;BR /&gt;m = month(datepart(varname));&lt;BR /&gt;&lt;BR /&gt;Will that do?&lt;BR /&gt;&lt;BR /&gt;Or maybe your original variable is a character string and you could use:&lt;BR /&gt;&lt;BR /&gt;m = substr(varname, 3, 3);</description>
      <pubDate>Fri, 30 Dec 2022 02:57:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/month-of-time/m-p/851572#M336589</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-12-30T02:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: month of time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/month-of-time/m-p/851578#M336592</link>
      <description>&lt;P&gt;This seems to be a datetime variable, that is a numeric variable with a format attached displaying the value as date and time. Maybe it is a string. Impossible to know without seeing the result of proc contents of the dataset containing the variable.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 07:03:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/month-of-time/m-p/851578#M336592</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-12-30T07:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: month of time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/month-of-time/m-p/851593#M336601</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;noted, this can be a datetime variable (numeric) or a string. You can use PROC CONTENTS to find out what it is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the first case, get the date part, and use a format to get the month name, e.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Length Month $3;
Month=put(datepart(&amp;lt;column name&amp;gt;),monyy5.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The MONYY format actually gets both the month and the year, e.g. "JUN22", but because we set the length of the MONTH variable to 3, it will only contain "JUN".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the second case, you can use SUBSTR:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Length Month $3;
Month=substr(&amp;lt;column name&amp;gt;,3,3);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Dec 2022 09:47:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/month-of-time/m-p/851593#M336601</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2022-12-30T09:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: month of time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/month-of-time/m-p/851594#M336602</link>
      <description>Hi, thank you. It's Num 8 type DATETTIME. format.</description>
      <pubDate>Fri, 30 Dec 2022 09:51:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/month-of-time/m-p/851594#M336602</guid>
      <dc:creator>znhnm</dc:creator>
      <dc:date>2022-12-30T09:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: month of time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/month-of-time/m-p/851595#M336603</link>
      <description>It helped a lot, thank you!</description>
      <pubDate>Fri, 30 Dec 2022 10:01:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/month-of-time/m-p/851595#M336603</guid>
      <dc:creator>znhnm</dc:creator>
      <dc:date>2022-12-30T10:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: month of time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/month-of-time/m-p/851596#M336604</link>
      <description>&lt;PRE&gt;&lt;CODE class=""&gt;Data Question;
	Date_Time_Variable = Dhms('03JUN22'd,00,00,00);
	format Date_Time_Variable datetime. ;
run;

/* YOU CAN USE THIS COUSTOM FORMAT FOR MONTHS*/
Proc Format;
	value  MonthName    1 = "JAN"
						2 = "FEB"
						3 = "MAR"
						4 = "APR"
						5 = "MAY"
						6 = "JUN"
						7 = "JUL"
						8 = "AUG"
						9 = "SEP"
						10= "OCT"
						11= "NOV"
						12= "DEC"
						;
run;
	
Data Answer;
	set Question;
	*Extract Date from Date_Time_Variable;
	Date  = DatePart(Date_Time_Variable);
	*Extracting Month From Date using Month Function that will return corresponding month number (1 - 12);
	MonthNumber = Month(Date);
	*Creating another variable Month that will use the above created &lt;BR /&gt;        Format;
	Month = put(MonthNumber,MonthName.);
	format date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Dec 2022 10:05:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/month-of-time/m-p/851596#M336604</guid>
      <dc:creator>Ashish_Vashist</dc:creator>
      <dc:date>2022-12-30T10:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: month of time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/month-of-time/m-p/851605#M336609</link>
      <description>Thanks  lot for this! I was trying to find a solution to have it on both number on 3-letter format. I have it both with your way which is amazing.</description>
      <pubDate>Fri, 30 Dec 2022 11:11:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/month-of-time/m-p/851605#M336609</guid>
      <dc:creator>znhnm</dc:creator>
      <dc:date>2022-12-30T11:11:40Z</dc:date>
    </item>
  </channel>
</rss>

