Solved

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

Posted on 2013-06-20
2
466 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
[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
  • Learn & ask questions
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

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…
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…

751 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