Hi all,
I have been having some trouble to use this following function;
FINANCE('ACCRINT', issue, first-interest, settlement, rate, par-value, frequency, [basis]);
I used this syntax from here: https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=ds2ref&docsetTarget=n0xns...
My code is as follows:
data want;
set original;
format i_date MMDDYY10.;
informat i_date YYMMDD8.;
format fid_date MMDDYY10.;
informat fid_date YYMMDD8.;
format st_date MMDDYY10.;
informat st_dateYYMMDD8.;
AI= finance('accrint', i_date, fid_date, st_date, coupon/100, PRINCIPAL_AMT, INTEREST_FREQUENCY, 1);
run;
In my original file, the variables format /informat are as follows:
INTEREST_FREQUENCY, PRINCIPAL_AMT, coupon, i_date, fid_date and st_date:
length: 8
format: best12.
informat: best32.
In the output, "want" file is created but with missing values for the variable, "AI".
In the log, this kind of message is generated:
NOTE: Argument 4 to function FINANCE('accrint',20041116,20090401,16715,0.1025,1000,2,1) at line
830 column 6 is invalid.
Variables description .....................
NOTE: Argument 4 to function FINANCE('accrint',20041116,20090401,16719,0.1025,1000,2,1) at line
830 column 6 is invalid.
Variables description .....................
REPEATS AGAIN............
ERROR: There was a problem with the format so BEST. was used
ERROR: There was a problem with the format so BEST. was used
................................................................
Please, help me with what changes I should make in my code. It would be a great help if you can correct my original code.
Thanks in Advance!!!!!
Your values i_date and fid_date are not dates just large numbers. That is why you get
NOTE: Argument 4 to function FINANCE('accrint',20041116,20090401,16715,0.1025,1000,2,1) at line 830 column 6 is invalid.
The st_date value of 16715 is 06OCT2005.
An example of turning such numeric values like 20041116 into dates:
data ; x=20041116; put x= date9.; date = input(put(x,f8.),yymmdd10.); put date date9.; run;
The above format date9. for x does not display a value because it is way past the range of values SAS will use for dates, meaning past the year 20,000 (yes 4 zeroes and almost 18,000 years in the future).
The display format of the date value has no impact on any function using the value, such as the Finance function, unless you PUT into a specific character value, which Finance won't like.
https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/... has a PDF with much information about dates.
In the original file, the variable: (st_date) was in regular date format
format: MMDDYY10.
informat: YYMMDD8.
Your values i_date and fid_date are not dates just large numbers. That is why you get
NOTE: Argument 4 to function FINANCE('accrint',20041116,20090401,16715,0.1025,1000,2,1) at line 830 column 6 is invalid.
The st_date value of 16715 is 06OCT2005.
An example of turning such numeric values like 20041116 into dates:
data ; x=20041116; put x= date9.; date = input(put(x,f8.),yymmdd10.); put date date9.; run;
The above format date9. for x does not display a value because it is way past the range of values SAS will use for dates, meaning past the year 20,000 (yes 4 zeroes and almost 18,000 years in the future).
The display format of the date value has no impact on any function using the value, such as the Finance function, unless you PUT into a specific character value, which Finance won't like.
https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/... has a PDF with much information about dates.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.