BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Nirmol
Fluorite | Level 6

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!!!!!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

 

 

View solution in original post

3 REPLIES 3
Nirmol
Fluorite | Level 6

In the original file, the variable:  (st_date) was in regular date format

format: MMDDYY10.

informat: YYMMDD8.

ballardw
Super User

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.

 

 

NadiaBeasley
Calcite | Level 5
I understand perfectly well that nothing will work out just like that; it is necessary to undergo training in this area. I have been looking for good business courses for a long time. I think that I can find good courses with you. Of course, before that, I studied various articles about investing and how to do business correctly and found an attractive site that talked about investments and deposits https://investorjunkie.com/crypto/inside-satoshi-islands-bid-to-become-a-cryptopia/ (which may be helpful to someone). In general, I am interested which courses to take and where it is more interesting to study. Maybe someone who has been trained can share their experience.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 663 views
  • 0 likes
  • 3 in conversation