<?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 extract year from a character variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/extract-year-from-a-character-variable/m-p/113991#M23493</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a character variable with the following data:&lt;BR /&gt;9/6/2013 11:16:13 AM&lt;BR /&gt;8/2/1994 4:18:06 PM&lt;BR /&gt;11/15/1995 3:54:36 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How would I go about extracting the four-digit year (eg 2013)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 16 Oct 2013 17:05:18 GMT</pubDate>
    <dc:creator>gzr2mz39</dc:creator>
    <dc:date>2013-10-16T17:05:18Z</dc:date>
    <item>
      <title>extract year from a character variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-year-from-a-character-variable/m-p/113991#M23493</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a character variable with the following data:&lt;BR /&gt;9/6/2013 11:16:13 AM&lt;BR /&gt;8/2/1994 4:18:06 PM&lt;BR /&gt;11/15/1995 3:54:36 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How would I go about extracting the four-digit year (eg 2013)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Oct 2013 17:05:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-year-from-a-character-variable/m-p/113991#M23493</guid>
      <dc:creator>gzr2mz39</dc:creator>
      <dc:date>2013-10-16T17:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: extract year from a character variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-year-from-a-character-variable/m-p/113992#M23494</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try using the scan function with a space and / as delimiter. &lt;/P&gt;&lt;P&gt;year=scan(var, 3, "/", 's');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Documentation on the SCAN function is here:&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214639.htm" title="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214639.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>Wed, 16 Oct 2013 17:10:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-year-from-a-character-variable/m-p/113992#M23494</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-10-16T17:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: extract year from a character variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/extract-year-from-a-character-variable/m-p/113993#M23495</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;input var$40.;&lt;/P&gt;&lt;P&gt;year=year(input(var,ANYDTDTE32.));&lt;/P&gt;&lt;P&gt;put year=;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;9/6/2013 11:16:13 AM&lt;/P&gt;&lt;P&gt;8/2/1994 4:18:06 PM&lt;/P&gt;&lt;P&gt;11/15/1995 3:54:36 PM&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Oct 2013 17:22:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/extract-year-from-a-character-variable/m-p/113993#M23495</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-10-16T17:22:24Z</dc:date>
    </item>
  </channel>
</rss>

