Monday, April 12, 2010

Get The Last Day of The Month

Suppose you have a date and want to get the last date of the month of this date. You can accomplish this easily by using INTNX function. Here is the SAS code which does that:


data demo;
format a b mmddyy10.;

a = '02-FEB-2008'd;
/* specifying 'e' will give you the last day of the month */
b = intnx('mon', a, 0,'e');
run;



You can further explore INTNX by reading this paper:
http://www2.sas.com/proceedings/sugi31/027-31.pdf