|
Larry,
A solution will depend on what you would consider as invalid but here is a
start for you to consider -
options yearcutoff=1600;/*** force yearcutoff to be outlandish ***/
data test;
file print;
length obs 8 dob $10;
infile cards missover;
input obs dob $ ;
dob2 = input(dob,mmddyy10.);
if '01jan1699'd ge dob2 then dob2 = .;
format dob2 date9.;
cards;
1 07-16-0000
2 07-16-0001
3 07-16-0999
4 07-16-0800
5 07-16-9999
6 05-03-9950
7 05-03/1950
8 05 16 1950
;;;;
run;
Records 1 and 2 will be considered invalid because of my check to see if
date is less than or equal to January 1, 1699.
Records 3 and 4 will be invalid by SAS automatically.
Records 5 - 7 will be valid dates, so you will need to determine what maybe
invalid for VERY FUTURE YEARS
Record 8 is invalid because dob will only get "05" assigned unless you use
an informat "$char10.", and in that case, Record 8 would then be OK.
So, trying to use straight date input will not provide a 100% guarantee you
will process in valid dates.
Another possibility is to break up the fields on your input like month, day
and year. And then create edits for each field or combination of fields,
and finally if you have a valid date, you can then create DOB2 as a SAS
Date Value Variable.
Not sure I have explained the reason why is does not work the way you think
it would but I am sure one of the SAS developers at SI could explain why
having "00xx" will work but not "0yyy" won't.
HTH,
Charles Patridge
Email: Charles_S_Patridge@prodigy.net
|