Solved

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

Posted on 2013-06-20
2
425 Views
Last Modified: 2013-06-21
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
Comment
Question by:morinia
2 Comments
 
LVL 14

Accepted Solution

by:
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

by:morinia
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Video by: Steve
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…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now