Help using Base SAS procedures

calculate implied volatillity by Black-Schole model and NLP

Reply
Occasional Contributor bqk
Occasional Contributor
Posts: 16

calculate implied volatillity by Black-Schole model and NLP

i want to calculate implied volatility using proc NLP

the code is like following

proc nlp data=AA outest=BB;
min error ;
PARMS sig=0.01;
d1=(log(SPXclose/(strike_price/1000))+(rate+((sig**2)/2))*TTM)/(sig*sqrt(TTM));
d2=d1-(sig*sqrt(TTM));
ee=((strike_price/1000)*exp((-rate)*TTM)*probnorm(-d2) - SPXclose*probnorm(-d1))-(best_ask+best_bid)/2;
error=abs(ee);
run;


however it does not work

the information in the log is following

NOTE: Your code contains 4 program statements.
NOTE: Gradient is computed using analytic formulas.
NOTE: Hessian is computed using analytic formulas.
ERROR: The variable SPXclose was referenced but not given a value.
ERROR: The variable strike_price was referenced but not given a value.
ERROR: The variable rate was referenced but not given a value.
ERROR: The variable TTM was referenced but not given a value.
ERROR: The variable best_ask was referenced but not given a value.
ERROR: The variable best_bid was referenced but not given a value.
WARNING: Your program statements contain 6 symbols used but not given a value.
WARNING: None of the data set variables are used in the program statements.
ERROR: There are references to missing variables when the program code is executed for _OBS_= 1
WARNING: Your program statements cannot be executed completely.
WARNING: In a total of 1 calls an error occurred during execution of the program statements.
NLP attempted to recover by using a shorter step size.

i can not understand where is the problem?

please help me, thanks for your help~
Valued Guide
Valued Guide
Posts: 684

Re: calculate implied volatillity by Black-Schole model and NLP

The most obvious problem: you are using several undefined variables, such as strike_price. Unless these are all variables in your data set, exactly as typed here, the program will not run. With SAS, sometimes one early error can then result in a long string of subsequent errors.
Occasional Contributor bqk
Occasional Contributor
Posts: 16

Re: calculate implied volatillity by Black-Schole model and NLP

i do not know how to input my data to proc nlp
could anyone support me a example, thanks~
Valued Guide
Valued Guide
Posts: 684

Re: calculate implied volatillity by Black-Schole model and NLP

You obviously have not learned how to use SAS yet. You actually specified the data file as AA, so I am guessing that this is just followed from an example. NLP is one of the most sophisticated procedures in SAS, requiring a knowledge of SAS and programming, as well as numerical optimization methods. You need to learn how to use sas data steps and procedures first.
Ask a Question
Discussion stats
  • 3 replies
  • 415 views
  • 0 likes
  • 2 in conversation