* Adding 3 months to a given date is more difficult than it first looks. * Increasing the number of months by 3 (and subtracting 12 if results exceed 12) gives results such as * for 31/3/2000 --> 31/6/2000 (but June has only 30 days). * Adding 90 or 91 days also produce weird results such as * for 2000/12/1 --> 2001/03/02 (see variable dtpls91 in data editor). * rlevesque@videotron.ca. DATA LIST /date1(DATE12). BEGIN DATA. 30-DEC-1999 31-JAN-2000 29-MAR-1999 30-MAR-1999 31-MAR-1999 1-APR-1999 5-FEB-1999 28-NOV-1999 29-NOV-1999 30-NOV-1999 28-NOV-2000 29-NOV-2000 30-NOV-2000 15-DEC-1998 1-DEC-2000 1-DEC-1999 END DATA. SORT CASES BY date1. COMPUTE day1=XDATE.MDAY(date1). COMPUTE month1=XDATE.MONTH(date1). COMPUTE year1=XDATE.YEAR(date1). EXECUTE. DO IF (ANY(month1,1,3,8) & (day1=31)). COMPUTE flag=1. COMPUTE date2=DATE.DMY(30, month1 +3,year1). ELSE IF ( (month1=11) & (day1>28) ). * in next compute. the 86400 is 60*60*24 that is the number of seconds in one day. * By subtracting one day from March 1st, results self adjust for leap years. COMPUTE date2=DATE.DMY(1,3,year1+1)-86400. COMPUTE flag=2. ELSE IF (month1<10). COMPUTE date2=DATE.DMY(day1, month1 + 3 ,year1). COMPUTE flag=3. ELSE. COMPUTE flag=4. COMPUTE date2=DATE.DMY(day1, month1-9 ,year1+1). END IF. COMPUTE dtpls91=date1+91*86400. FORMAT date2 dtpls91(DATE12). VARIABLE WIDTH date1 date2(13). EXECUTE.