<?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 How do I extract the month and year from a date? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-extract-the-month-and-year-from-a-date/m-p/212143#M52400</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Friends,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to get my mind around this issue, and I need your advice regarding it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a variable "Date" in my sas dataset in the format "01DEC05".&lt;/P&gt;&lt;P&gt;I want to extract the month "DEC", and the year "05" using the DATA step.&lt;/P&gt;&lt;P&gt;So far I tried using the SUBSTR(Right &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt; function; it does work for the char variable but it does not work for the numeric variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's my code:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;data work.stocks;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;set sashelp.stocks;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Inital=substr(Stock,1,1);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Month=SUBSTR(Date,3,3);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Year=SUBSTR(Date,6,2);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;put @1 Month @5 Year;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;run;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;This being my first post here, my apologies if the code tags are not inserted properly.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Best Regards&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;asar_k&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Ref:&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212264.htm" title="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212264.htm"&gt;SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 09 May 2015 06:50:04 GMT</pubDate>
    <dc:creator>asar_k</dc:creator>
    <dc:date>2015-05-09T06:50:04Z</dc:date>
    <item>
      <title>How do I extract the month and year from a date?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-extract-the-month-and-year-from-a-date/m-p/212143#M52400</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Friends,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to get my mind around this issue, and I need your advice regarding it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a variable "Date" in my sas dataset in the format "01DEC05".&lt;/P&gt;&lt;P&gt;I want to extract the month "DEC", and the year "05" using the DATA step.&lt;/P&gt;&lt;P&gt;So far I tried using the SUBSTR(Right &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt; function; it does work for the char variable but it does not work for the numeric variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's my code:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;data work.stocks;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;set sashelp.stocks;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Inital=substr(Stock,1,1);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Month=SUBSTR(Date,3,3);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Year=SUBSTR(Date,6,2);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;put @1 Month @5 Year;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;run;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;This being my first post here, my apologies if the code tags are not inserted properly.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Best Regards&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;asar_k&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Ref:&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212264.htm" title="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212264.htm"&gt;SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 May 2015 06:50:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-extract-the-month-and-year-from-a-date/m-p/212143#M52400</guid>
      <dc:creator>asar_k</dc:creator>
      <dc:date>2015-05-09T06:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract the month and year from a date?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-extract-the-month-and-year-from-a-date/m-p/212144#M52401</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;d='01mar2015'd;&lt;/P&gt;&lt;P&gt;m=put(d,monname3.);&lt;/P&gt;&lt;P&gt;y=put(d,year4.);&lt;/P&gt;&lt;P&gt;put m= y=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 May 2015 13:32:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-extract-the-month-and-year-from-a-date/m-p/212144#M52401</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-05-09T13:32:39Z</dc:date>
    </item>
  </channel>
</rss>

