BookmarkSubscribeRSS Feed
xyxu
Quartz | Level 8

I am trying to to calculate bond yield using SAS function YIELDP (link). 

 

I followed the function's description to call: 

 

 ytm = yieldp(100, coupon / 100, 2, k, k0, price_dirty);

 

The function returns reasonable values for most observations, but I do get many error massages:


NOTE: Argument 1 to function YIELDP(100,0.013,2,1,0.002739726,99.053592466) at line 2149 column 11 is invalid.
offering_date=20141015 maturity=20170615 COUPON=1.3 CRSP_PORTNO=1026667 REPORT_DT=20161231 NBR_SHARES=10000000
MARKET_VAL=9839825.00 cusip_8digit=00507UAB cusip=00507UAB7 price=98.39825 rating_num=11 rating_date=20161208
rating_round=12 month=2016-12-31 rating_group=BBB k=1 k0=0.002739726 ai=0.6553424658 price_dirty=99.053592466 ytm=.
_ERROR_=1 _N_=119156
NOTE: Argument 1 to function YIELDP(100,0.0511,2,4,0.1698630137,12.93) at line 2149 column 11 is invalid.
offering_date=20010410 maturity=20190315 COUPON=5.11 CRSP_PORTNO=1031647 REPORT_DT=20170430 NBR_SHARES=507340
MARKET_VAL=57075.75 cusip_8digit=009451AP cusip=009451AP0 price=11.25 rating_num=1 rating_date=20141120 rating_round=2
month=2017-04-30 rating_group= k=4 k0=0.1698630137 ai=1.68 price_dirty=12.93 ytm=. _ERROR_=1 _N_=190181
NOTE: Argument 1 to function YIELDP(100,0.0511,2,4,0.0849315068,13.613999443) at line 2149 column 11 is invalid.
offering_date=20010410 maturity=20190315 COUPON=5.11 CRSP_PORTNO=1023709 REPORT_DT=20170531 NBR_SHARES=727506
MARKET_VAL=83663.24 cusip_8digit=009451AP cusip=009451AP0 price=11.499999443 rating_num=1 rating_date=20170531
rating_round=2 month=2017-05-31 rating_group= k=4 k0=0.0849315068 ai=2.114 price_dirty=13.613999443 ytm=. _ERROR_=1
_N_=190182

The input values seem valid. Is there any reason behind these messages? 

7 REPLIES 7
PGStats
Opal | Level 21

If you are running an older version of SAS (prior to 9.4 TS1M3), this problem might be a known bug. See:

 

Problem Note 57781: The YIELDP function returns "NOTE: Invalid argument to function YIELDP" 

PG
xyxu
Quartz | Level 8
I am running on SAS 9.4. The reported issues seem to be related to 9.2, so I guess there might be something else going on here
PGStats
Opal | Level 21

It was only fixed in 9.4 TS1M3...

PG
xyxu
Quartz | Level 8
Just checked mine, it is 9.4 (TS1M3 MBCS3170)
Reeza
Super User
I would also try your code using SAS Academics on Demand with the same values to see if it errors out first, then you can concretely say the issue isn't fixed in your version. Either way sounds like it may be time to raise a ticket with SAS Tech Support.
PGStats
Opal | Level 21

Still errs in SAS On Demand (9.4 ts1m6)

 

 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         data test;
 70         COUPON=1.3;
 71         k=1;
 72         k0=0.002739726;
 73         price_dirty=99.053592466;
 74         ytm = yieldp(100, coupon / 100, 2, k, k0, price_dirty);
 75         run;
 
 NOTE: Argument 1 to function YIELDP(100,0.013,2,1,0.002739726,99.053592466) at ligne 74 colonne 7 is invalid.
 COUPON=1.3 k=1 k0=0.002739726 price_dirty=99.053592466 ytm=. _ERROR_=1 _N_=1
 NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to 
       missing values.
       Each place is given by: (Number of times) at (Line):(Column).
       1 à 74:7   
 NOTE: The data set WORK.TEST has 1 observations and 5 variables.
 NOTE: DATA statement a utilisé (Durée totale du traitement) :
       real time           0.00 seconds
       cpu time            0.00 seconds
       

Either the function needs more fixing or the doc needs updating.

 

PG
Reeza
Super User
Error messages need updating but I'm also seeing some weird data there so I think the data doesn't quite follow the expected logic/relationship expected for a bond in certain cases. Are you certain these are all valid values for this function?

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 934 views
  • 5 likes
  • 3 in conversation