BookmarkSubscribeRSS Feed
BhararaTej
Fluorite | Level 6

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

4 REPLIES 4
Reeza
Super User

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? 

 

 

PGStats
Opal | Level 21

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
ChrisNZ
Tourmaline | Level 20

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

 

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 2242 views
  • 1 like
  • 5 in conversation