For some reason we often make SAS dates more complicated than necessary when working with them in the macro language. Remember that a date value is just a number. The date constant form such as '31Jul2012'd is actually a function call that is translated to a number, 19205. Therefore there is no reason to convert a SAS date to a text string and then convert it back to a number. For instance: %let test_end_date = %sysfunc(intnx(month, "&sysdate"d, &shift, e), date9.); For today's date the value of &test_end_date is 31jul2012. and when used in the constant "&test_end_date"d resolves to 19205. We can simplify by going directly to the actual date. The %LET becomes: %let test_end_date = %sysfunc(intnx(month, "&sysdate"d, &shift, e)); &test_end_date now contains 19205 and it can be used directly in a comparison: %let date_string = &test_start_date <= date <= &test_end_date;
... View more