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
Solved

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

Posted on 2013-06-20
2
456 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
understanding output of mysql version 2 65
t-sql sp_addlinkedserver possible risks 3 93
Mysql Left Join Case 10 70
Display SQL 2008 last modified/update Database 11 15
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
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…

856 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