<?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: SAS EG - Substract year from DATE9 variable in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Substract-year-from-DATE9-variable/m-p/926755#M44729</link>
    <description>&lt;P&gt;Both the YEAR function and the YEAR format expect an input value which represents a SAS date. SAS stores dates as counts of days, with 1960-01-01 being day zero.&lt;/P&gt;
&lt;P&gt;Since the result of the YEAR&amp;nbsp;&lt;EM&gt;function&lt;/EM&gt; is &lt;U&gt;not&lt;/U&gt; a SAS date, but the &lt;U&gt;year number&lt;/U&gt;, applying the DATE&amp;nbsp;&lt;EM&gt;format&lt;/EM&gt; to the result will interpret this number as a count of days and come up with a year of 1965 for the value of 2024.&lt;/P&gt;
&lt;P&gt;For the display of a year value like the number 2024, no format is needed. It's just a 4-digit number, unless you reached so far into the future that you went past 9999.&lt;/P&gt;</description>
    <pubDate>Thu, 02 May 2024 09:31:12 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2024-05-02T09:31:12Z</dc:date>
    <item>
      <title>SAS EG - Substract year from DATE9 variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Substract-year-from-DATE9-variable/m-p/926745#M44727</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;In my dataset I have a date (document_date) listed in format DATE9. I would like to add an additional column which gives you the YEAR of 'document_date'. I've tried the following things, but it is not giving me the year. What am I doing wrong?&lt;/P&gt;&lt;P&gt;1. Add a computed column YEAR(t1.document_date) in format YEAR4 --&amp;gt; gives me 17JUL1965&lt;/P&gt;&lt;P&gt;2. Add t1.document_date as an additional column and give it format YEAR4 --&amp;gt; the output is the same as the input&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2024 08:39:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Substract-year-from-DATE9-variable/m-p/926745#M44727</guid>
      <dc:creator>user34567</dc:creator>
      <dc:date>2024-05-02T08:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG - Substract year from DATE9 variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Substract-year-from-DATE9-variable/m-p/926750#M44728</link>
      <description>&lt;P&gt;Your 2nd options sounds like something that should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  document_date='25Feb2024'd;
run;

proc sql;
  select 
    document_date
    ,document_date as document_date_2 format=date9.
    ,document_date as document_date_3 format=year4.
  from have
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1714640757859.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96126i802A1134644C9D94/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1714640757859.png" alt="Patrick_0-1714640757859.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2024 09:06:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Substract-year-from-DATE9-variable/m-p/926750#M44728</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-05-02T09:06:26Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG - Substract year from DATE9 variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Substract-year-from-DATE9-variable/m-p/926755#M44729</link>
      <description>&lt;P&gt;Both the YEAR function and the YEAR format expect an input value which represents a SAS date. SAS stores dates as counts of days, with 1960-01-01 being day zero.&lt;/P&gt;
&lt;P&gt;Since the result of the YEAR&amp;nbsp;&lt;EM&gt;function&lt;/EM&gt; is &lt;U&gt;not&lt;/U&gt; a SAS date, but the &lt;U&gt;year number&lt;/U&gt;, applying the DATE&amp;nbsp;&lt;EM&gt;format&lt;/EM&gt; to the result will interpret this number as a count of days and come up with a year of 1965 for the value of 2024.&lt;/P&gt;
&lt;P&gt;For the display of a year value like the number 2024, no format is needed. It's just a 4-digit number, unless you reached so far into the future that you went past 9999.&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2024 09:31:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Substract-year-from-DATE9-variable/m-p/926755#M44729</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-05-02T09:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG - Substract year from DATE9 variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Substract-year-from-DATE9-variable/m-p/926765#M44730</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Thank you for your explanation. I've set the format to 'none' and now it indeed works!&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2024 10:43:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Substract-year-from-DATE9-variable/m-p/926765#M44730</guid>
      <dc:creator>user34567</dc:creator>
      <dc:date>2024-05-02T10:43:19Z</dc:date>
    </item>
  </channel>
</rss>

