***** * This is p4b.sas - main program for testing pin estimation in SAS - in ~/proj/pincalscs/test **; options ls=max ps=max nocenter fullstimer source date number formdlim = '.' ; options mlogic mprint symbolgen ; libname here '.'; libname taqbs '.'; ************************* ; * macro pincalc estimates PINs using IGP model ; * ; * input file must contain fields called buys, sells and with an identifying group variable ; * that is passed to the macro ; *********************************************************** ; *********************************************************** ; * The file pinmacros.sas defines the macros pincalc, lkstar_nz and BesselKstarJmhlf ; *********************************************************** ; %include "./pinmacros.sas"; * options obs = 1000; data buysell; set here.buysell; run; /*--------------------------------------------------------------------*/ /* Get the data ready for the NLP procedure. */ /*-------------------------------------------------------------------*/ proc sort data=buysell; by permno year ; run; *********************** ; * %pincalcvdj(_infile, _parest, _likedat, _buyvar, _selvar, _firmidvar ) ; * _infile is the input data set ; * _parest is the output data set to contain the parameter estimates ; * _likedat is the output dataset that will contain the likelihood ; * estimates ; * _buyvar is the name of the BUYS variable ; * _selvar is the name of the SELLS variable ; * _firmidvar is the name of the variable(s) that identifies the ; * firm-period (typically PERMCO YEAR) ; * ; *********************** ; %pincalcvdj( buysell, here.pinsvdjtemp, here.llvdjtemp , dbuys , dsells , permno year ) ; proc sort data = here.pinsvdjtemp; by permno year; run; data here.pinsvdjtemp (drop =alpha mu epsi) ; set here.pinsvdjtemp ; by permno year ; pinvdj = alpha * mu / (alpha * mu + 2.0 * epsi) ; label pinvdj = 'Probability of informed trading - vdj model' ; alphavdj = alpha; muvdj = mu; epsivdj = epsi; format pinvdj alphavdj epsivdj muvdj 5.3 ; run; ************************************ ; * print the output for reviewing oddities ; ************************************ ; proc print u data = here.pinsvdjtemp ; title "here.pinstemp - based on vdj pin"; run; proc print u data = here.llvdjtemp (obs = 10) ; title "here.lltemp - based on vdj pin"; run; %pincalceko( buysell, here.pinsekotemp, here.llekotemp , dbuys , dsells , permno year ) ; proc sort data = here.pinsekotemp; by permno year; run; data here.pinsekotemp (drop =alpha mu epsi) ; set here.pinsekotemp ; by permno year ; pineko = alpha * mu / (alpha * mu + 2.0 * epsi) ; label pineko = 'Probability of informed trading - eko model' ; alphaeko = alpha; mueko = mu; epsieko = epsi; format pineko alphaeko epsieko mueko 5.3 ; run; ************************************ ; * print the output for reviewing oddities ; ************************************ ; proc print u data = here.pinsekotemp ; title "here.pinstemp - based on EKO pin"; run; proc print u data = here.llekotemp (obs = 10) ; title "here.lltemp - based on EKO pin"; run; data bothpins; merge here.pinsekotemp here.pinsvdjtemp; by permno year; run; proc corr data = bothpins; var pinvdj pineko alphavdj alphaeko epsivdj epsieko muvdj mueko; run;