|
V6-INFORMATS-F682
Reading character dates containing a century indicator
|
Date values that contain a century indicator, denoted by the letter C,
that are not in the form of cyymmdd can be read in as character. Other
forms of date values may be cmmddyy or cddmmmyy, where a value of 0
(zero) for 'C' would indicate the 20th century (i.e. 19nn) and a value
of 1 (one) would indicate the 21st century (i.e. 20nn). This example
reads each portion of the date as character, adjusts the year based on
the century indicator, concatenates the "pieces", and uses the INPUT
function with appropriate informats:
data test;
input c $1. m $2. d $2. y $2. ;
if c = '0' then year = '19'||y;
else if c = '1' then year = '20'||y;
sasdate = input(m||d||year,mmddyy8.);
format sasdate date9.;
cards;
0050399
1050301
;
If dates are in form cyymmdd, refer to SAS Note V6-INFORMATS-F677.
| Products: | BASE |
| Component: | INFORMATS |
| Priority: | N/A |
| Status: | Usage Issue |
| Date: | Mon, 22 Feb 1999 |
| System | Release Reported | Release Fixed |
| VM/ESA (CMS) | 6.09 TS450 | |
| OS/390 (MVS) | 6.09 TS450 | |
| OpenVMS VAX | 6.09 TS450 | |
| AIX/6000 | 6.12 TS020 | |
| HP-UX Operating Systems | 6.12 TS020 | |
| IBM OS/2 | 6.12 TS020 | |
| Solaris | 6.12 TS020 | |
| OpenVMS Alpha | 6.12 TS020 | |
| Windows 3.11 | 6.12 TS020 | |
| Windows NT | 6.12 TS020 | |
| Windows 95 | 6.12 TS020 | |
| Compaq Tru64 Unix | 6.12 TS040 | |
| Macintosh | 6.12 TS040 |
No Fixes Available