基于sas系統(tǒng)金融計(jì)算隨書光盤char_第1頁
基于sas系統(tǒng)金融計(jì)算隨書光盤char_第2頁
基于sas系統(tǒng)金融計(jì)算隨書光盤char_第3頁
基于sas系統(tǒng)金融計(jì)算隨書光盤char_第4頁
基于sas系統(tǒng)金融計(jì)算隨書光盤char_第5頁
已閱讀5頁,還剩12頁未讀, 繼續(xù)免費(fèi)閱讀

付費(fèi)下載

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

n=2datadox1=1to6;dox2=1to6; goptionsftext=swissctext=blackhtext=1cells;/*symbolv=squarec=blueh=1cells;/*規(guī)定數(shù)據(jù)點(diǎn)的圖形符號(hào)、符號(hào)高度、線條顏色*/dataa;seta;procunivariatedata=anoprint;/*這里使用univariate過程檢驗(yàn)是否符合正態(tài)分布*/varx;histogram/caxes=blackcframe=cxf7e1c2waxis1/*軸寬度圖填充樣式

cbarline=blackcfill=bluepfill=solid/*vscale=percenthminor=1vminor=0/*規(guī)定坐標(biāo)軸刻度、縱軸刻線密度*/name='hist'/*規(guī)定輸出圖形名稱*/normal(mu=estsigma=estw=1color=rednoprint*形,規(guī)定圖形寬度、顏色,其中均值和標(biāo)準(zhǔn)差由估計(jì)得到;insetnormal;goptionsftextctext= dataa;dox1=1to6;dox2=1to6;dox3=1to6; goptionsftext=swissctext=blackhtext=1symbolv=squarec=blueh=1cells;dataa;seta;procunivariatedata=a varx;histogram/caxes=blackcframe=cxf7e1c2waxis=cbarline=blackcfill=bluepfill=solidvscale=percenthminor=1vminor=0normal(mu=estsigma=estw=1color=rednoprint;insetnormal;goptionsftext=ctext=%macroa(n); datarv;dom=1toifm=0thenprobb=probbnml(0.8,&n,0);/*probbnml函數(shù)返回以0.8、n、0為參數(shù)的二項(xiàng)分elseprobb=probbnml(0.8,&n,m)-probbnml(0.8,&n,m-1));/*注意到probbnml函數(shù)返回累 width=6c=blueh=1cells*規(guī)定兩點(diǎn)之間的插值方法、線條寬度、procgplotdata=rv;plotprobb*m=1;%mend(p=0.8N=10,20,25,50,200,1000%macroa(n);datarv;retain_seed_0;do_i_=1to&n;binom1ranbin(_seed_,&n,0.8);/*ranbin函數(shù)返回以seed、n、0.8為參數(shù)的二項(xiàng)分布隨機(jī)drop_seed__i_;goptionsftext=swissctext=blackhtext=1cells;symbolv=squarec=blueh=1cells;procunivariatedata=rvnoprint;varbinom1;histogram/caxes=blackcframe=cxf7e1c2waxis=1cbarline=blackcfill=bluepfill=solidvscale=percenthminor=1vminor=0normal(mu=estsigma=estw=1color=rednoprint;insetnormal;goptionsftext=ctext=%mendoptionsnodatenonotesnosource;datarv;%macro%doi=1 /*eval返回參數(shù)&y*/dataa;retain_seed_0; do_i_=1to100;exp&i=ranexp(_seed_)/6;drop_seed__i_;datarv;mergervdatarv(keep=s&y);*/setrv;s&y=sum(ofexp1-goptionsftext=swissctext=blackhtext=1cells;symbolv=squarec=blueh=1cells;procunivariatedata=rv vars&y;histogram/caxes=blackcframe=cxf7e1c2waxis=1cbarline=blackcfill=bluepfill=solidvscale=percenthminor=1vminor=0normal(mu=estsigma=estw=1color=rednoprint;insetnormal;goptionsftext=ctext=%mendoptionsnodatenonotesnosource;datarv;%macro%do dataretain_seed_do_i_=1toexp&i=ranexp(_seed_)/6;drop_seed__i_;datarv;mergervdatarv(keep=x&y);setrv;x&y=sum(ofexp1-exp&y)/&y;*與上面例子的不同之處在于這里除以&y*/goptionsftext=swissctext=blackhtext=1cells;symbolv=squarec=blueh=1cells;procunivariatedata=rvnoprint;varx&y;histogram/caxes=blackcframe=cxf7e1c2waxis=1cbarline=blackcfill=bluepfill=solidvscale=percenthminor=1vminor=0normal(mu=estsigma=estw=1color=rednoprint;insetnormal;goptionsftext=ctext=%mend例optionsnodatenonotesdatarv; retain_seed_0;do_i_=1toexp=ranexp(_seed_)/6;drop_seed_datarv80; %macro%doi=1 dataa;setrv;procsql;createviewtmp select*,ranuni(0)as_ran_froma orderbycalculated_ran_; datasettmp(obs=80);/*取前80個(gè)*/drop_ran_;renameexp=exp&i;datarv80;mergerv80datarv80(keep=s&y);setrv80;s&y=sum(ofexp1-goptionsftext=swissctext=blackhtext=1cells;symbolv=squarec=blueh=1cells;procunivariatedata=rv80 vars&y;histogram/caxes=blackcframe=cxf7e1c2waxis=1cbarline=blackcfill=bluepfill=solidvscale=percenthminor=1vminor=0normal(mu=estsigma=estw=1color=rednoprint;insetnormal;goptionsftext=ctext=%mendoptionsnodatenonotesnosource;datarv;retain_seed_do_i_=1toexp=ranexp(_seed_)/6;drop_seed__i_;樣本容量分別為 50和 抽180次樣。X的分布模擬optionsnodatenonotesdatarv&y;%doi=1 dataa;setrv;procsql; createviewtmpasselect*,ranuni(0)as_ran_fromaorderbycalculated_ran_;datasettmp(obs&y);*取前&y個(gè)觀測值*/drop_ran_;procmeansdata=randomnoprint;varexp;outputout=bmean=exp_m;datarv&y;setrv&yb;/*通過這個(gè)語句,使每次宏得到的exp_m全部匯總到rv&y這個(gè)文件中了goptionsftext=swissctext=blackhtext=1cells;symbolv=squarec=blueh=1cells;procunivariatedata=rv&y varexp_m;histogram/caxes=blackcframe=cxf7e1c2waxis=1cbarline=blackcfill=bluepfill=solidvscale=percenthminor=1vminor=0normal(mu=estsigma=estw=1color=rednoprint;insetnormal;goptionsftext=ctext=%menddatainputusage@@;/*@@使得cards語句中向后數(shù)據(jù),而不是換行*/242442421803228624753234190137414303290736772153289218783014328426952870294720092320188535572803393319013071180621532801319221373494295032822748379729802390327437852497301820514398348737974052363841702088236021704002219737313796307618074395337033634119251035702126320719583896196421332774286536303021209634813711352522253332291140903313277623143798277236442461;datadmdtb44;setdmdtb44;hn=_n_;/*生成序號(hào)*/樣本容量分別為 60,抽180次樣,隨機(jī)模擬均值的分布o(jì)ptionsnodatenonotesdatarv&y;%doi=1%to%eval(&z);dataa;setdmdtb44;procsql;createviewtmpselect*,ranuni(0)as_ran_fromaorderbycalculated_ran_;datasettmp(obs=&y); drop_ran_;procmeansdata=randomnoprint;varusage;outputout=bmean=usage_m;datarv&y;setrv&ygoptionsftext=swissctext=blackhtext=1cells;symbolv=squarec=blueh=1cells;procunivariatedata=rv&y varusage_m;histogram/caxes=blackcframe=cxf7e1c2waxis=1cbarline=blackcfill=bluepfill=solidvscale=percenthminor=1vminor=0normal(mu=estsigma=estw=1color=rednoprint;insetnormal;goptionsftext=ctext=%menddataa;dotime=-50toiftime>0thenoutput;/*實(shí)際上是去掉最開始的51個(gè)數(shù)據(jù)*/ procgplotsymbol1v=pointi=joinc=blue;/*規(guī)定符號(hào)樣式、插值方法、線條顏色*/symbol2v=nonei=r;/*i=r規(guī)定生成一條一次的回歸曲線(直線)*/plotp*time=1p*time=2/overlay;/*在一張圖中產(chǎn)生兩條曲線,分別使用樣式1和樣式2*/例dataa;dotime=-50to1000;iftime>0thenoutput;procgplotsymbol1v=pointi=joinc=blue;symbol2v=nonei=r;plotp*time=1p*time=2/overlay;dataa;dotime=-10tosigma=1+(100<=time<=200);*time在[100,200]區(qū)間上,標(biāo)準(zhǔn)差為2,其它區(qū)間為1*/iftime>0thenoutput;procgplotsymbol1v=stari=joinc=blue;symbol2v=nonei=r plotp*time=1p*time=2/overlay;ARIMA例dataa;dotime=-50to1000;iftime>0thenoutput;e1=e;*兩個(gè)滯后變量的實(shí)現(xiàn)*/procgplotsymbol1v=stari=joinc=green;symbol2v=nonei=r plotr*time=1r*time=2/overlay;GARCHdatav1=0.01;*設(shè)定初值dotime=-50to1000;v=epxl+mu1*v1+mu2*v2;*兩階滯后變量的實(shí)現(xiàn)*/iftime>0thenoutput;h1=h;/*三個(gè)滯后變量*/procgplotsymbol1v=pointi=joinc=blue;symbol2v=nonei=r;plotr*time=1r*time=2/overlay;13.3.5SAS/*RDMRBP聯(lián)合分布的1000個(gè)隨機(jī)數(shù)隨機(jī)數(shù)*/prociml;cov2=t(cov1);/*轉(zhuǎn)置cov3={10.675,0.6751};/*生成2×2矩陣*/cov=(cov1*cov2)#cov3;/*矩陣相乘*/cov1cov2cov3;/*釋放cov1、cov2、cov3*/callvnormal(et,mu,cov1000);/*生成二維正態(tài)隨機(jī)序列et,均值向是為mu /*寫成colname1={'dm','bp'};也可以*/createafromet[colname=colname1];appendfromet; proccorrdata=a;vardmbp;/*計(jì)算對(duì)不同的組合下的收入,每種組合有1000種收入情況*/datab;setdodokb=1.30,1.25ifkd=0.66thencd=0.085855;ifkd=0.65thencd=0.032191;ifkd=0.64thencd=0.20795;ifkd=0.63thencd=0.017001;ifkd=0.62thencd=0.013711;ifkd=0.61thencd=0.010851;ifkd=0.60thencd=0.008388;ifkd=0.59thencd=0.006291;ifkd=0.55thencd=0.001401;ifkb=1.30thencb=0.137;ifkb=1.25thenifkb=1.20thencb=0.045060;ifkb=1.15thencb=0.028338;ifkb=1.10thencb=0.016146;ifkb=1.05thencb=0.007860;ifkb=1.00thencb=0.003277;ifkb=0.95thencb=0.001134;ifkb=0.90then rall_nhedg=645*0.6513*(1+dm)+272*1.234*(1+bp);/*不對(duì)沖的總收入*/組

procsortdata=b;bykdkb;datac;setb;doi=1to if1000*(i-1)<_n_<=1000*ithenindex=i; datac;setc;ifrall<=706theni=0;elsei=1;/*加標(biāo)識(shí)i,以區(qū)別外匯收入是否大于7.06億*//*計(jì)算收入大于706百萬的概率*/procmeansdata=cnoprint;varikdkbrallclass outputout=dmean=imkdmkbprall_mrall_nhedg_m/*指定輸出均值的變量名*/std=i_stdkd_stdkb_stdrall_std rall_nhedg_std/*指定輸出標(biāo)準(zhǔn)差的變量名*/sum=isxysrall_srall_nhedg_s/*指定輸出和的變量名*/lclm=i_lkd_lkb_lrall_lrall_nhedg_l/*指定輸出95%置信區(qū)間下界的變量名*/uclm=i_ukd_ukb_urall_urall_nhedg_u;/*指定輸出95%置信區(qū)間上界的變量名*/datad;setd; datad;setd;if_n_=1thendelete;*刪掉procmeansprocsortbydescendingprob;/*降序排列*/datad;setd;labelkdm='(dm)的執(zhí)行價(jià)格';labelkbp='英鎊(bp)的執(zhí)行價(jià)格';labelprob='收入大于706百萬的概率';labelindex='序列號(hào)filenamenewd:\1.txt';/*new是文件1.txt的標(biāo)識(shí)procprinttoprint=new;*輸出到文件new,即1.txt中*/procprintdata=dlabelnoobs;procprinttoprint=print;(c)下面改變的數(shù)量來比較組合的收益情況,結(jié)果如下/*改變數(shù)量的模擬情況*/datab;setdond=100,300,500; /*加入DM和BP的數(shù)量*/donb=100,300,500;dodokb=1.30,1.25ifkd=0.66thencd=0.085855;ifkd=0.65thencd=0.032191;ifkd=0.64thencd=0.20795;ifkd=0.63thencd=0.017001;ifkd=0.62thencd=0.013711;ifkd=0.61thencd=0.010851;ifkd=0.60thencd=0.008388;ifkd=0.59thencd=0.006291;ifkd=0.55thencd=0.001401;ifkb=1.30thencb=0.137;ifkb=1.25thenifkb=1.20thencb=0.045060;ifkb=1.15thencb=0.028338;ifkb=1.10thencb=0.016146;ifkb=1.05thencb=0.007860;ifkb=1.00thencb=0.003277;ifkb=0.95thencb=0.001134;ifkb=0.90thenrall_nhedg=645*0.6513*(1+dm)+2

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論