Some Excel functions are already implemented in SAS using FCMP custom functions : http://www.sascommunity.org/wiki/Excel_functions_in_SAS Complete doc for FCMP : FCMP :: Base SAS(R) 9.4 Procedures Guide, Third Edition A nice presentation by SAS R&D : http://www.gasug.org/papers/ProcFCMP.pptx Here is, for instance, the Excel DATDIF function coded into SAS as a SAS function called DATDIF4_SLK :
proc fcmp OUTLIB=SASHELP.SLKWXL.finance;
function datdif4_slk(start, end)
label="European DATDIF";/*-----------------------------------------------------------------
* ENTRY: datdif4_slk
*
* PURPOSE: Returns the number of days between two dates using
* the European '30/360' method of calculation.
*
* USAGE: numdays = datdif4_slk( start, end );
* start - the start date from which to calculate
* number of days, expressed as SAS date
* value, e.g., '15feb98'd.
* end - the end date from which to calculate
* number of days, expressed as SAS date
* value, e.g., '15mar98'd.
*
* NOTES: If either start date or end date is on the 31st of
* a month, then it is set equal to the 30th of the same
* month. If the start date is on the last day of a
* February, then the difference between 30 and the
* length of the same year's February is added to the
* usual U.S.(NASD) method of '30/360' day count basis.
*-----------------------------------------------------------------*/
startday = day(start);
startmon = month(start);
startyear = year(start);
endday = day(end);
endmon = month(end);
endyear = year(end);
if startday = 31 then
startday = 30;
if endday = 31 then
endday = 30;
restart = mdy(startmon,startday,startyear);
reend = mdy(endmon,endday,endyear);
datdif4 = datdif(restart,reend,'30/360');
/* adjust for february start and falls on the last day of february */
febstart = mdy(2,1,startyear);
marstart = mdy(3,1,startyear);
feblength = datdif(febstart,marstart,'act/act');
if feblength = 28 & startday = 28 then
datdif4 = datdif(start,end,'30/360') + 2;
if feblength = 29 & startday = 29 then
datdif4 = datdif(start,end,'30/360') + 1;
return(datdif4);
endsub;
run;
quit;
... View more