|Summary of Potential Problem Areas|
It is important to be aware of all aspects of your data processing
environment that may cause misinterpretation of dates. This includes all files
and programs in your SAS libraries, as well as files and raw data from external
sources. The following list contains potential problem areas:
- Input data screens may contain two-digit
date fields to save keystrokes.
- SAS programs
- may write dates with two-digit years to output
such as reports and external files
- may misinterpret two-digit years in input data
- may misinterpret two-digit years in
elements such as date constants or arguments to date functions.
- SAS datasets may contain two-digit
years stored in character or non-SAS date or datetime numeric variables.
- Raw data may contain two-digit
- Display or print output headers may
display two-digit years.
|Practices That Help Insure Date Integrity|
The following practices help ensure that your date values are
correct during all the conversions that occur during processing:
- Store dates as SAS date values, not as simple
numeric or character values.
- Use the YEARCUTOFF= system option when converting
two-digit dates to SAS date values.
- Examine sets of raw data coming into your SAS
process to make sure that any dates containing two-digit years will be correctly
interpreted by the YEARCUTOFF= system option. Look out for
- two-digit years that are distributed over more
than a 100-year period. For dates covering more than a 100-year span, you
must either use four digit years in the data, or use conditional logic in
a DATA step to interpret them correctly.
- two-digit years that need an adjustment to the
default YEARCUTOFF= range. For example, if the default value for YEARCUTOFF=
in your operating environment is 1920 and you have a two-digit date in your
data that represents 1919, you will have to adjust your YEARCUTOFF= value
downward by a year in the SAS program that processes this value.
- Make sure that output SAS data sets represent
dates as SAS date values.
- Check your SAS programs to make sure that formats
and informats that use two-digit years, such as DATE7., MMDDYY6., or MMDDYY8.,
are reading and writing data correctly.
Note: The YEARCUTOFF= option has no effect on dates
that are already stored as SAS date values.
|Tools That Help Ensure Data Integrity|
is a summary of the SAS System tools you'll be using to insure the integrity
of your date-related data.
- YEARCUTOFF= SAS system option
- specifies the proper century to associate
with two-digit years.
Note: A Technical Tip on the YEARCUTOFF= option is available
from the SAS web site: http://www.sas.com/techsup/download/technote/ts597.html.
- informats, formats and functions
- are SAS System language elements that handle
a wide variety of reading, writing and formatting operations related to dates
and time, such as
- converting dates from one format to another, such
as mmddyy to mmddyyyy
- converting dates to SAS date values, so that numeric
operations may be performed on them
- converting SAS date or datetime values back to
a variety of date or time formats, such as 062099, or June 20, 1999.
|Strategies for Fixing Problems|
Not all potential problems need to be corrected. If your SAS
program writes out date values with two-digit years, you may not need to modify
the program if the year can be correctly inferred from the context. For example,
a printed report listing expiration dates for current drivers licenses can
use two-digit years. However, if the same program writes out the dates to
a file, and a subsequent application reads the two-digit year and subtracts
it from another two-digit year, then the program(s) should be changed. Here
are some (but by no means all) steps you can take to correct potential compliance
- Make sure that an appropriate value for the YEARCUTOFF=
option is specified in your application. The specific value to use will obviously
depend on the range of dates your applications use. Note that if all of your
applications use the same general range, you can set the YEARCUTOFF= option
at the system level so that all applications use the same default. Note also
that you can specify the option at any point in your program to adjust for
different date ranges in different input files.
- Make sure all date information is stored as SAS
date variables. Various functions are available to convert date information
from other formats to SAS date values. This may also require modifying subsequent
statements in your program to process the values as date values, but doing
this will save you trouble in the long run.
- Change instances of two-digit year date formats
(such as DATE7.) to four-digit years (such as DATE9.). This may not always
be practical, particularly when you write output files, since the format of
the file (and any applications that process it) may need to be modified to
adjust for the extra digits.
- Modify applications that input date information
through screens or forms to require or allow four-digit years.
- If variables in SAS data sets are assigned permanent
formats, use PROC DATASETS or a DATA step to change the formats to ones using
- Assign appropriate formats and controls to date
fields that are imported through SAS/ACCESS interfaces.
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.