<?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 YEARCUTOFF=ERROR in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/YEARCUTOFF-ERROR/m-p/468377#M119620</link>
    <description>&lt;P&gt;Is there a system option or similar that could be used to generate an ERROR whenever SAS relies on the value of the YEARCUTOFF option in order to interpret an ambiguous years?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below illustrates how SAS uses YEARCUTOFF to interpret a two-digit year or one-digit year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;347  options yearcutoff=1800 ;
348  data _null_ ;
349    x1='7JUN2018'd ;
350    x2='7JUN18'd ;
351    x3='7JUN8'd ;
352    put x1= x2= x3= ;
353    format x1 x2 x3 date9. ;
354  run;

x1=07JUN2018 x2=07JUN1818 x3=07JUN1808
&lt;/PRE&gt;
&lt;P&gt;I think I want something like YEARCUTOFF=ERROR, so that any time SAS tried to use the value of year cut off, it would return an error.&amp;nbsp; This would be an offensive programming option, to say "I don't want my program to tolerate years with less than four digits."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I vaguely remember for Y2K the company I was at had some add-on (?) that would generate a NOTE or WARNING in the log whenever code had a two-digit year.&amp;nbsp; But I don't think it was an official SAS product, and I don't remember how it worked.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there's no good way to do this now, I'll submit it as a ballot item.&lt;/P&gt;</description>
    <pubDate>Thu, 07 Jun 2018 14:25:59 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2018-06-07T14:25:59Z</dc:date>
    <item>
      <title>YEARCUTOFF=ERROR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/YEARCUTOFF-ERROR/m-p/468377#M119620</link>
      <description>&lt;P&gt;Is there a system option or similar that could be used to generate an ERROR whenever SAS relies on the value of the YEARCUTOFF option in order to interpret an ambiguous years?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below illustrates how SAS uses YEARCUTOFF to interpret a two-digit year or one-digit year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;347  options yearcutoff=1800 ;
348  data _null_ ;
349    x1='7JUN2018'd ;
350    x2='7JUN18'd ;
351    x3='7JUN8'd ;
352    put x1= x2= x3= ;
353    format x1 x2 x3 date9. ;
354  run;

x1=07JUN2018 x2=07JUN1818 x3=07JUN1808
&lt;/PRE&gt;
&lt;P&gt;I think I want something like YEARCUTOFF=ERROR, so that any time SAS tried to use the value of year cut off, it would return an error.&amp;nbsp; This would be an offensive programming option, to say "I don't want my program to tolerate years with less than four digits."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I vaguely remember for Y2K the company I was at had some add-on (?) that would generate a NOTE or WARNING in the log whenever code had a two-digit year.&amp;nbsp; But I don't think it was an official SAS product, and I don't remember how it worked.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there's no good way to do this now, I'll submit it as a ballot item.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 14:25:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/YEARCUTOFF-ERROR/m-p/468377#M119620</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2018-06-07T14:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: YEARCUTOFF=ERROR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/YEARCUTOFF-ERROR/m-p/468384#M119622</link>
      <description>&lt;P&gt;I'm not sure if this would help jog your memory, but you can certainly capture the YEARCUTOFF value using:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%let y = %sysfunc(getoption(yearcutoff));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 14:32:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/YEARCUTOFF-ERROR/m-p/468384#M119622</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-06-07T14:32:24Z</dc:date>
    </item>
    <item>
      <title>Re: YEARCUTOFF=ERROR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/YEARCUTOFF-ERROR/m-p/468395#M119626</link>
      <description>&lt;P&gt;Yeah, but it's not that I want to capture the value of YEARCUTOFF.&amp;nbsp; I want a way to tell SAS that I don't want to use YEARCUTOFF to interpret ambiguous years. I want my session to expect four digit years from my code and data, and return an error if it finds a two digit year.&amp;nbsp; So this would be for strict error handling, along the lines of&amp;nbsp;varinitchk=error,&amp;nbsp;varlenchk=error, or my favorite undocumented&amp;nbsp;dsoptions=note2err.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Over time I've become a fan of offensive programming that errs on the side of throwing too many errors rather handling errors.&amp;nbsp; This thought about YEARCUTOFF was prompted today because over on SAS-L it was pointed out that SAS date literals don't mind random text at the end, so SAS is happy to accept junk like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1    data _null_ ;
2      x="07Jun1meh"d ;
3      put x date9.;
4    run ;

07JUN2001
&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;Because it ignores the text at the end, and interprets the 1 as a one-digit year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 14:48:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/YEARCUTOFF-ERROR/m-p/468395#M119626</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2018-06-07T14:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: YEARCUTOFF=ERROR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/YEARCUTOFF-ERROR/m-p/468403#M119627</link>
      <description>&lt;P&gt;Is the concern here about date literals or Informat behavior? I suspect the data literal behavior is going to be somewhat different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is likely a PITA but you could do something like set the YEARCUTOFF to something extremely unlikely, such as 2200. Then any time dealing with the dates if the Year is &amp;gt; 2200 set an error message. Or perhaps a custom date range for "likely" date ranges.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;options yearcutoff=2200;
proc format library=work;
value mydates
'01JAN1960'D - '31DEC2030'd = [mmddyy10.]
other = "_error_";
run;
data junk;
   x='01Jan01'd;
   format x mydates.;
run;

options yearcutoff=1926;&lt;/PRE&gt;
&lt;P&gt;You could test the result of the format to actually throw an error in a data step if desired.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 15:04:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/YEARCUTOFF-ERROR/m-p/468403#M119627</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-07T15:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: YEARCUTOFF=ERROR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/YEARCUTOFF-ERROR/m-p/468411#M119631</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;.&amp;nbsp; The concern is really the broad issue of how SAS handles a year value&amp;nbsp;that has less than four digits.&amp;nbsp; So would apply to date literals, informats, functions that create date values from text, etc etc.&amp;nbsp; Generally I expect my code and data to have four-digit years.&amp;nbsp; If it encounters a year with less than four digits (in any context), I'd like it to be an error.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Agree, I think setting yearcutoff to an unusual value is the best that could be done currently.&amp;nbsp; But that forces you to add code to check each date value, which as you say is a hassle, and feels dangerous because you're intentionally risking creating invalid data that could be treated as valid.&amp;nbsp; It's kind of like using -99 for missing values instead of special missing values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would be nice to have a way to say "Hey SAS, if you don't know what year a value represents, don't guess!"&amp;nbsp; (To be more fair: "don't interpret the year according to the 100 year range specified in YEARCUTOFF").&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 15:27:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/YEARCUTOFF-ERROR/m-p/468411#M119631</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2018-06-07T15:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: YEARCUTOFF=ERROR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/YEARCUTOFF-ERROR/m-p/468424#M119640</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;.&amp;nbsp; The concern is really the broad issue of how SAS handles a year value&amp;nbsp;that has less than four digits.&amp;nbsp; So would apply to date literals, informats, functions that create date values from text, etc etc.&amp;nbsp; Generally I expect my code and data to have four-digit years.&amp;nbsp; If it encounters a year with less than four digits (in any context), I'd like it to be an error.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Agree, I think setting yearcutoff to an unusual value is the best that could be done currently.&amp;nbsp; But that forces you to add code to check each date value, which as you say is a hassle, and feels dangerous because you're intentionally risking creating invalid data that could be treated as valid.&amp;nbsp; It's kind of like using -99 for missing values instead of special missing values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would be nice to have a way to say "Hey SAS, if you don't know what year a value represents, don't guess!"&amp;nbsp; (To be more fair: "don't interpret the year according to the 100 year range specified in YEARCUTOFF").&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sounds like a Ballot option might be in order to see if you can get enough support.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I already have enough date checking such as "are people visiting the clinic before they are born" in my projects the yearcutoff isn't a major concern.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 15:56:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/YEARCUTOFF-ERROR/m-p/468424#M119640</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-07T15:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: YEARCUTOFF=ERROR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/YEARCUTOFF-ERROR/m-p/616253#M180392</link>
      <description>&lt;P&gt;I added the ballot item:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SASware-Ballot-Ideas/New-option-YearCutoff-ERROR-to-generate-error-when-encountering/idi-p/508496" target="_blank"&gt;https://communities.sas.com/t5/SASware-Ballot-Ideas/New-option-YearCutoff-ERROR-to-generate-error-when-encountering/idi-p/508496&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2020 16:28:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/YEARCUTOFF-ERROR/m-p/616253#M180392</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2020-01-09T16:28:28Z</dc:date>
    </item>
  </channel>
</rss>

