We help IT Professionals succeed at work.

Compa;ring two dates in SAS

morinia used Ask the Experts™
I have two dates in SAS.  Both are defined as:
 Num       8    DATE9.    DATE9

Both dates contain  02AUG2011

What is the syntax to compare DATEA to DATEB.  They are not comparing as equal.

I am trying to use this statement:

proc sql undo_policy=none;
        create table C as
        select                           a.mbr_id
            , a.date
            , b.date
            from filea a left join fileb b      
                           on a.mbr_id=bmbr_id      
                            and a.date= b.date;
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
what's the error you are getting?

if you had copied the code and pasted into the question, then it appears that there's a problem with your code: a.mbr_id=bmbr_id <- shouldn't it be b.mbr_id?

assuming that it is a genuine typo, then might be worthwhile looking at the actual value stored in the table...
moriniaAdvanced Analytics Analyst


It was a typo.

Even if I use a dat step the two dates do not compare equal and the data in both fields has the same description in a proc contents and the data in the date field is the same.

instead of formatting the field as date9. could you change it to best. so that the actual value stored can be displayed? what are the values?
moriniaAdvanced Analytics Analyst


You are correct.  The values I thought were equal actually have

18841 for the first date  and  18841.4492 on the second date