Solved

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

Posted on 2013-06-20
466 Views
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
Question by:morinia
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 14

Accepted Solution

Aloysius Low earned 250 total points
ID: 39264846
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

Author Closing Comment

ID: 39265704
It worked fine.  Even though I have birthdate in the example, i am just using that macro to calculate a time period of enrollment which will always begin the first of the month and end on the last day of the month.  In this case I wanted to be able to calculate one month for a person enrolled for just month.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

### Suggested Solutions

Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
###### Suggested Courses
Course of the Month3 days, 22 hours left to enroll