BookmarkSubscribeRSS Feed
bqk
Calcite | Level 5 bqk
Calcite | Level 5
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~
3 REPLIES 3
lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12
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.
bqk
Calcite | Level 5 bqk
Calcite | Level 5
i do not know how to input my data to proc nlp
could anyone support me a example, thanks~
lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12
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.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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