DATA Step, Macro, Functions and more

re: Number of Days between two date with Leap Year

Accepted Solution Solved
Reply
Regular Contributor
Posts: 222
Accepted Solution

re: Number of Days between two date with Leap Year

Hi....I am trying to calculate the number of days from a clients DOB and a date. I am using INTCK Function and it seems to work until the clients DOB falls on a Leap year. Any suggestions to to fix this....Thanks

 

((intck('Day',input(put(client_dob,8.),yymmdd8.),input(put(date,8.),yymmdd8.),'c'))) as Number_Days


Accepted Solutions
Solution
‎08-23-2016 07:59 PM
Super User
Posts: 5,085

Re: re: Number of Days between two date with Leap Year

Have you checked your leap years to make sure the dates are valid?  For example, if your data set contains 19930229, you should be getting an error because there is no February 29 in the year 1993.

View solution in original post


All Replies
Super User
Posts: 17,840

Re: re: Number of Days between two date with Leap Year

Please post dates to indicate how the results don't match what you're expecting.

 

Otherwise, simply subtract the two dates to get the number of days.

Solution
‎08-23-2016 07:59 PM
Super User
Posts: 5,085

Re: re: Number of Days between two date with Leap Year

Have you checked your leap years to make sure the dates are valid?  For example, if your data set contains 19930229, you should be getting an error because there is no February 29 in the year 1993.

Regular Contributor
Posts: 222

Re: re: Number of Days between two date with Leap Year

[ Edited ]

Hi Astounding....I think you found the problem....the DOB is 19320229 and the birthdate occurring during the fiscal year from 20140401 to 20150331 is probably not a leap year.

Super User
Posts: 17,840

Re: re: Number of Days between two date with Leap Year

No the problem is 1993 is not a leap year, therefore there's no Feb 29th and that's an incorrect DOB, SAS date value.

Contributor
Posts: 34

Re: re: Number of Days between two date with Leap Year

You have written C in the quatation marks. what is that meant for ?

please help.

((intck('Day',input(put(client_dob,8.),yymmdd8.),input(put(date,8.),yymmdd8.),'c')))

Regular Contributor
Posts: 222

Re: re: Number of Days between two date with Leap Year

Hi Vandhan,

 

The 'C' is an optional parameter which refers to the method of 'Continuous'. The alternative method, which is the default method, is 'Discrete'. These optional parameters can be used when calculating the difference between two dates and the 'Continuous' method actually calculates continuous time from the start-of-period date specified in the second parameter of INTCK function.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 332 views
  • 1 like
  • 4 in conversation