
If you are inputing two digits years, you may encounter the option "yearcutoff".
How to control the prefix? Like if you have two digit year number "18", how can you get "1918" rather than "2018"?
First, let's check the option "yearcutoff".
Here is a good
explaination:
Before you use the YEARCUTOFF= system option, examine the dates in your data:
- If the dates in your data fall within a 100-year span, you can use the YEARCUTOFF= system option.
- If the dates in your data do not fall within a 100-year span, you must either convert the two-digit years to to four-digit years or use a DATA step with conditional logic to assign the proper century prefix.
Once you've determined that the YEARCUTOFF= system option is appropriate for your range of data, you can determine the setting to use. The best setting for YEARCUTOFF= is a year just slightly lower than the lowest year in your data. For example, if you have data in a range from 1921 to 1999, set YEARCUTOFF= to 1920, if that is not already your system default. The result of setting YEARCUTOFF= to 1920 is that
- SAS interprets all two-digit dates in the range of 20 through 99 as 1920 through 1999.
- SAS interprets all two-digit dates in the range 00 through 19 as 2000 through 2019.
The following figure shows the span of years when the YEARCUTOFF= option is set to a value of 1920. The 100-year span in this case is from 1920 to 2019.
Span of Years When the YEARCUTOFF= Option Is Set to 1920
![[IMAGE]](http://v8doc.sas.com/sashtml/lrcon/images/01405164.gif)
With YEARCUTOFF= set to 1920, a two-digit year of 10 would be interpreted as 2010, and a two-digit year of 22 would be interpreted as 1922.
Learn by example
Now let's code.
/* macro variable to store the path */
%let path=C:\Documents and Settings\Administrator\My Documents\Dropbox\Transfer\tech post\yearcutoff;
options yearcutoff = 1820;
proc options option = yearcutoff;
run;
data year_1820;
input month day year;
bday = mdy(month, day, year);
format bday date9.;
cards;
7 11 18
7 11 48
1 1 60
;
run;
options yearcutoff = 1920;
proc options option = yearcutoff;
run;
data year_1920;
input month day year;
bday = mdy(month, day, year);
format bday date9.;
cards;
7 11 18
7 11 48
1 1 60
;
run;
Result