turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- calculate difference in 2 dates based on 360 days ...

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-07-2016 10:27 PM

Hi,

I have a code that we are looking to automate which currently some part of it is in excel.

It is basically calculating difference in dates based on an excel function day360 which calculates difference in dates based on a 360 day year.

I am hoping to replicate this code in SAS and I know we can use intck to calculate difference in dates, but looking for suggestions/ inputs to calculate difference in dates based on a 360 day year in SAS.

Appreciate the help.

Tej

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to BhararaTej

11-07-2016 10:35 PM

It looks like the calculation is the number of months multiplied by 30 days.

You can use INTNX to move the date to the end/beginning/same of an interval as required.

Was the third parameter in Excel True or False?

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to BhararaTej

11-07-2016 11:11 PM

You can emulate the European method with:

```
day360 = intck("MONTH", date_a, date_b) * 30 +
min(30, day(date_b)) - min(30, day(date_a));
```

PG

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to BhararaTej

11-07-2016 11:46 PM - edited 11-07-2016 11:54 PM

Like this?

```
proc fcmp outlib=WORK.FUNC.TEST;
function days360(END, START);
Y=intck('year',START, END);
N=Y*360+intck('day',START,intnx('year',END,-Y,'s'));
return (N);
endsub;
run;
options cmplib=WORK.FUNC;
data _null_;
END = '07dec2016'd;
START = '8nov2014'd;
DAYS = days360(END, START);
putlog DAYS=;
run;
```

DAYS=749

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to BhararaTej

11-08-2016 01:28 AM

You want calculate the number of years between two date ? Check function YRDIF(start,end,'30/360');