BookmarkSubscribeRSS Feed

A long time ago, we all learned that 2-digit years are bad.

 

SAS itself is Y2K compliant, but if user-written code (or data) has two-digit years (or one-digit years!), SAS is left to impute the century by referring to the setting of the YEARCUTOFF option.  Below illustrates how YEARCUTOFF can be used to impute century (and even decade):

 

1    options yearcutoff=1800 ;
2    data _null_ ;
3      x1='7JUN2018'd ;
4      x2='7JUN18'd ;
5      x3='7JUN8'd ;
6      x4='7JUN8fooooo'd ;
7      put x1= x2= x3= x4= ;
8      format x1 x2 x3 x4 date9. ;
9    run;

x1=07JUN2018 x2=07JUN1818 x3=07JUN1808 x4=07JUN1808

I think it would be helpful to have an option like YEARCUTOFF=ERROR or NOYEARCUTOFF.  This would say "If SAS encounters a year with less than four digits, generate an error message, rather than using YEARCUTOFF to impute the century."

 

While it can sometimes be helpful to write code that is tolerant to two-digit years, it would be useful to be able turn on stricter error handling which requires all years to be four digits.

 

Related discussion thread: https://communities.sas.com/t5/SAS-Programming/YEARCUTOFF-ERROR/m-p/468377/highlight/true#M119620

1 Comment
lc_isp
Obsidian | Level 7

If I may dare to give a (newbie) suggestion: options y2k_check=[on|off]; (strict y2k compliance test).