Reading Date and Time Values | |
Reading Dates and Times Using
Informats |
Four-Digit Year Values
The value of the YEARCUTOFF= system option only affects two-digit year values. A date value that contains a four-digit year value will be interpreted correctly even if it does not fall within the 100-year span set by the YEARCUTOFF= system option. |
Date Expression | SAS Date Informat | Interpreted As |
---|---|---|
06Oct59 | date7. | 06Oct1959 |
17Mar1783 | date9. | 17Mar1783 |
However, if you specify an inappropriate field width, you will receive incorrect results. Notice that the date expression in the table below contains a four-digit year value. The informat does not specify a w value large enough to read the entire value, so the last two digits of the year are truncated. |
Date Expression | SAS Date Informat | Interpreted As |
---|---|---|
17Mar1783 | date7. | 17Mar1917 |
Another problem arises if you read a date or time expression using the wrong informat. The SAS log displays an invalid data message, and the variable's values are set to missing. |
1---+----10 |
03/23/98 |
SAS Log
3 input BirthDate date8.; 4 run; NOTE: Invalid data for BirthDate in line 3 1-8. RULE: ----+----1----+----3----+----4----+----5 3 03/23/98 BirthDate=. _ERROR_=1 _N_=1 |
When you work with date and time values,
|
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.