<?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: Getting the YY only from DATE() in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Getting-the-YY-only-from-DATE/m-p/17812#M2608</link>
    <description>needs minor revision (cannot apply the year format to the value returned by the year() function)[pre]YRF    = PUT(DATEvariable,year2.);[/pre] But that dateVariable could be formatted in the put statement, since the string variable is not used elsewhere.&lt;BR /&gt;
I would not use this routine with the date function, but that is just my personal preference. I don't often have to prepare programs to run where date() might return a different year from the year in constant &amp;amp;sysdate. (Does one of the BI servers create that situation?)&lt;BR /&gt;
PeterC</description>
    <pubDate>Tue, 17 Nov 2009 20:15:30 GMT</pubDate>
    <dc:creator>Peter_C</dc:creator>
    <dc:date>2009-11-17T20:15:30Z</dc:date>
    <item>
      <title>Getting the YY only from DATE()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-the-YY-only-from-DATE/m-p/17809#M2605</link>
      <description>Hi all&lt;BR /&gt;
&lt;BR /&gt;
I am trying to get the YY part of the YEAR() function and write it out to a dataset but cannot get this done.&lt;BR /&gt;
&lt;BR /&gt;
This is my code:&lt;BR /&gt;
&lt;BR /&gt;
DATA XXX;&lt;BR /&gt;
YR = YEAR(DATE());   &lt;BR /&gt;
FORMAT YR $04.;      &lt;BR /&gt;
YRF = SUBSTR(YR,3,2);&lt;BR /&gt;
&lt;BR /&gt;
FILE MERGED;                      &lt;BR /&gt;
  PUT   @001   RECORDH        $01.&lt;BR /&gt;
        @002   MTH            2.  &lt;BR /&gt;
        @004   YRF            $02.&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
But this only writes out a blank - what am i missing?&lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
      <pubDate>Tue, 17 Nov 2009 06:29:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-the-YY-only-from-DATE/m-p/17809#M2605</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-11-17T06:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the YY only from DATE()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-the-YY-only-from-DATE/m-p/17810#M2606</link>
      <description>use the year format with length 2, like[pre]   put @4 date year2. ;[/pre]&lt;BR /&gt;
PeterC</description>
      <pubDate>Tue, 17 Nov 2009 08:32:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-the-YY-only-from-DATE/m-p/17810#M2606</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-11-17T08:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the YY only from DATE()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-the-YY-only-from-DATE/m-p/17811#M2607</link>
      <description>Peter has a solution, but your problem is that you have mixed up numeric and character data types.  You should have gotten lots of warnings about converting numeric to character or vice-versa.&lt;BR /&gt;
&lt;BR /&gt;
The YEAR function returns a numeric value.  If you rewrote as&lt;BR /&gt;
&lt;BR /&gt;
DATA XXX;&lt;BR /&gt;
LENGTH yrf $ 2;&lt;BR /&gt;
YRF = PUT(YEAR(DATE()),year2.);&lt;BR /&gt;
&lt;BR /&gt;
FILE MERGED;&lt;BR /&gt;
PUT @001 RECORDH $01.&lt;BR /&gt;
@002 MTH 2.&lt;BR /&gt;
@004 YRF $02.&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
it should work (though you are missing other parts of your code).</description>
      <pubDate>Tue, 17 Nov 2009 16:21:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-the-YY-only-from-DATE/m-p/17811#M2607</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2009-11-17T16:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the YY only from DATE()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-the-YY-only-from-DATE/m-p/17812#M2608</link>
      <description>needs minor revision (cannot apply the year format to the value returned by the year() function)[pre]YRF    = PUT(DATEvariable,year2.);[/pre] But that dateVariable could be formatted in the put statement, since the string variable is not used elsewhere.&lt;BR /&gt;
I would not use this routine with the date function, but that is just my personal preference. I don't often have to prepare programs to run where date() might return a different year from the year in constant &amp;amp;sysdate. (Does one of the BI servers create that situation?)&lt;BR /&gt;
PeterC</description>
      <pubDate>Tue, 17 Nov 2009 20:15:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-the-YY-only-from-DATE/m-p/17812#M2608</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-11-17T20:15:30Z</dc:date>
    </item>
  </channel>
</rss>

