
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.
- 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.
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

No comments:
Post a Comment