x
• Status: Solved
• Priority: Medium
• Security: Public
• Views: 483

# computing the difference between Nov 1, 2013 and Nov 30, 2013 in SAS to equal 1 month

I have the following macro in SAS to compute the difference betwen two dates.  The problem I am having is I am getting 0 for the difference between Nov 1, 2013 and Nov 30, 2013.

I would like to get 1 for 1 month.

I am using the following macro.  Can someone tell me how to modify the macro to give me 1 .

%macro age_months(date,birth);
round ((intck('month',&birth,&date)
- (day(&date) < day(&birth))))
%mend age_months;
0
morinia
1 Solution

Commented:
I'm thinking of just doing
intck('month',&birth,&date+1)
inside the macro only.. mentally out works but nothing beats testing which I'm not able to do now..

I'm wondering - what if the date of birth of 1 Dec and date is 30 Dec - are u expecting value of 1 also? Intck with month as the interval works by giving the number of months between 2 dates thus if both dates have the same month and year the value will be 0.. you might need to consider checking if the dates have the same month and year then use the days interval instead of month interval.. and if the number of days is more than 28 for example then set the value to 1..
0