<?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 Converting 01JAN2008 (format: Date9.) to Year (2008) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-01JAN2008-format-Date9-to-Year-2008/m-p/417903#M102652</link>
    <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to convert a date variable with the following formatting&amp;nbsp;01JAN2008 (the format is Date9.)&amp;nbsp; to a date variable of year only (i.e. 2008).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please provide some guidance on the syntax to do that?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 02 Dec 2017 00:22:48 GMT</pubDate>
    <dc:creator>Jack_Smitherson</dc:creator>
    <dc:date>2017-12-02T00:22:48Z</dc:date>
    <item>
      <title>Converting 01JAN2008 (format: Date9.) to Year (2008)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-01JAN2008-format-Date9-to-Year-2008/m-p/417903#M102652</link>
      <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to convert a date variable with the following formatting&amp;nbsp;01JAN2008 (the format is Date9.)&amp;nbsp; to a date variable of year only (i.e. 2008).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please provide some guidance on the syntax to do that?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Dec 2017 00:22:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-01JAN2008-format-Date9-to-Year-2008/m-p/417903#M102652</guid>
      <dc:creator>Jack_Smitherson</dc:creator>
      <dc:date>2017-12-02T00:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: Converting 01JAN2008 (format: Date9.) to Year (2008)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-01JAN2008-format-Date9-to-Year-2008/m-p/417906#M102653</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;d = '01JAN2008'd;&lt;BR /&gt;format d date9.;&lt;BR /&gt;year=year(d);&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Dec 2017 00:34:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-01JAN2008-format-Date9-to-Year-2008/m-p/417906#M102653</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2017-12-02T00:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: Converting 01JAN2008 (format: Date9.) to Year (2008)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-01JAN2008-format-Date9-to-Year-2008/m-p/417908#M102654</link>
      <description>&lt;P&gt;You have a few options.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Convert it to a numerical variable, which is basically the year function&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;myDate = '01Jan2008'd;

myYear = year(myDate);

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2. You can use a format instead to change the appearance. PROC MEANS/FREQ/SUMMARY will respect the format, PROC SQL will not. This changes how the variable is display but not the underlying data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format myDate year4.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;3. You can do a combination of 1/2, supposing you wanted it as year but in a different variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;myYear = myDate;
format myYear year4.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Dec 2017 01:18:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-01JAN2008-format-Date9-to-Year-2008/m-p/417908#M102654</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-02T01:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: Converting 01JAN2008 (format: Date9.) to Year (2008)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-01JAN2008-format-Date9-to-Year-2008/m-p/418236#M102731</link>
      <description>&lt;P&gt;Thank you for your response. I do want to run some proc sql later on, so simply formatting the variable is not the most optimal option.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the first option you gave me "&lt;SPAN&gt;Convert it to a numerical variable, which is basically the year function" - how can I go about applying that to 12 months (i.e. 01Jan2000, 1Feb2000, 01Mar2000, etc.) with five years worth of data? (i.e. 2000-2004; I have a combination of 01Jan2000, 01Jan2001, 01Jan2002, etc.).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks again!&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2017 17:42:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-01JAN2008-format-Date9-to-Year-2008/m-p/418236#M102731</guid>
      <dc:creator>Jack_Smitherson</dc:creator>
      <dc:date>2017-12-04T17:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: Converting 01JAN2008 (format: Date9.) to Year (2008)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-01JAN2008-format-Date9-to-Year-2008/m-p/418238#M102732</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159570"&gt;@Jack_Smitherson&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for your response. I do want to run some proc sql later on, so simply formatting the variable is not the most optimal option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the first option you gave me "&lt;SPAN&gt;Convert it to a numerical variable, which is basically the year function" - how can I go about applying that to 12 months (i.e. 01Jan2000, 1Feb2000, 01Mar2000, etc.) with five years worth of data? (i.e. 2000-2004; I have a combination of 01Jan2000, 01Jan2001, 01Jan2002, etc.).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks again!&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That depends on your data structure.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the YEAR() function on the variable to obtain the YEAR.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2017 17:43:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-01JAN2008-format-Date9-to-Year-2008/m-p/418238#M102732</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-04T17:43:33Z</dc:date>
    </item>
  </channel>
</rss>

