<?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: DATETIME22.3 to year in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/DATETIME22-3-to-year/m-p/142676#M37949</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are various ways, using DATEPART and YEAR function or DTYEAR format, see below&lt;/P&gt;&lt;DIV style="font-family: Consolas; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; have;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; eventDate = datetime();&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; eventDate &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;datetime22.3&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; eventYear = year( datepart(eventDate) );&lt;BR /&gt;&amp;nbsp; eventYear_c = put(eventDate, &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;dtyear4.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Mar 2014 14:58:44 GMT</pubDate>
    <dc:creator>BrunoMueller</dc:creator>
    <dc:date>2014-03-13T14:58:44Z</dc:date>
    <item>
      <title>DATETIME22.3 to year</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/DATETIME22-3-to-year/m-p/142673#M37946</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am obviously a self taught SAS user and a newbie. Any sort of help is appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a variable called EVENTDATE and according to PROC CONTENTS the format for this variable is DATETIME22.3. I would like to run an analysis using only the year part --not interested about the month, day or time. Can anyone tell me the sas code so I can extract the year so I can run a basic analysis?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Mar 2014 14:50:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/DATETIME22-3-to-year/m-p/142673#M37946</guid>
      <dc:creator>NOA</dc:creator>
      <dc:date>2014-03-13T14:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME22.3 to year</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/DATETIME22-3-to-year/m-p/142674#M37947</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could try: year(*)&lt;/P&gt;&lt;P&gt;where the * is replaced by your date variable name.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Mar 2014 14:57:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/DATETIME22-3-to-year/m-p/142674#M37947</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-03-13T14:57:16Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME22.3 to year</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/DATETIME22-3-to-year/m-p/142675#M37948</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Year= year(datepart(variable));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or depending on the proc you can simply apply a format to your variable of&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;format variable dtyear.;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Mar 2014 14:58:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/DATETIME22-3-to-year/m-p/142675#M37948</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-03-13T14:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME22.3 to year</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/DATETIME22-3-to-year/m-p/142676#M37949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are various ways, using DATEPART and YEAR function or DTYEAR format, see below&lt;/P&gt;&lt;DIV style="font-family: Consolas; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; have;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; eventDate = datetime();&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; eventDate &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;datetime22.3&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; eventYear = year( datepart(eventDate) );&lt;BR /&gt;&amp;nbsp; eventYear_c = put(eventDate, &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;dtyear4.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Mar 2014 14:58:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/DATETIME22-3-to-year/m-p/142676#M37949</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2014-03-13T14:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME22.3 to year</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/DATETIME22-3-to-year/m-p/142677#M37950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mr. Bruno Muller thank you. It worked but for some reason the only year the comes out is 2014. I can see in the LOG that my EVENTDATE are all from today.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When i looked in the SQL server database I am using, the dates ranged from 2008-2014. Any idea what might be going on?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Mar 2014 15:22:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/DATETIME22-3-to-year/m-p/142677#M37950</guid>
      <dc:creator>NOA</dc:creator>
      <dc:date>2014-03-13T15:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME22.3 to year</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/DATETIME22-3-to-year/m-p/142678#M37951</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just in case the two lines&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;eventDate = datetime();&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; eventDate &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;datetime22.3&lt;/SPAN&gt;; &lt;/P&gt;&lt;P&gt;are only for testing purposes, they are not needed in your code&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Mar 2014 15:31:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/DATETIME22-3-to-year/m-p/142678#M37951</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2014-03-13T15:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME22.3 to year</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/DATETIME22-3-to-year/m-p/142679#M37952</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Post your code&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Mar 2014 15:32:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/DATETIME22-3-to-year/m-p/142679#M37952</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-03-13T15:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME22.3 to year</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/DATETIME22-3-to-year/m-p/142680#M37953</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I got it to work. Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Mar 2014 15:44:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/DATETIME22-3-to-year/m-p/142680#M37953</guid>
      <dc:creator>NOA</dc:creator>
      <dc:date>2014-03-13T15:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: DATETIME22.3 to year</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/DATETIME22-3-to-year/m-p/142681#M37954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;mark as answered please &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Mar 2014 15:51:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/DATETIME22-3-to-year/m-p/142681#M37954</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-03-13T15:51:14Z</dc:date>
    </item>
  </channel>
</rss>

