I have a table that has some basic info about patients named outpatient:
ID Date
A 10/04/11
B 10/18/11
C 11/30/11
In SAS when I check the Date column, I see that it has format MMDDYY8. and informat DATETIME20. For another step where I need to find the min Date:
proc sql;
create table outpatient2 as
select distinct ID, min(Date) as first_date datetime.
from outpatient
group by ID;
quit;
When I check the output it looks like this:
ID first_date
A 01JAN60:05:15:05
B 01JAN60:05:15:03
C 01JAN60:05:15:52
Because I had no time, my bad fix around was to send the outpatient table to oracle and call to it using this:
from userid.outpatient
I did check the oracle version in sas by setting it in a data step and it seems it is format and both informat DATETIME20. But using the bad fix around I get the correct output I was looking for:
ID first_date
A 05OCT11:00:00:00
B 25MAY11:00:00:00
C 09AUG11:00:00:00
Please disregard the dates exactly, they're sort of a random example to show that when Date is formatted MMDDYY8. and min(Date) is used, it returns an odd date but if Date is formatted DATETIME20. it returns the correct date.
Edit: There are no blank DATEs and although the outpatient2 step completes, I get an ERROR: Date value out of range.