sample.txt为上证指数 ,读入sas.
filename in 'c:\sample.txt';
data a;
infile in dlm='09'x;
input id date : yymmdd10. (x1-x7) (: $12.) ;
format date yymmdd10.;
proc print data=a;run;
进一步研究其开盘价趋势图:
data spprice( keep=price lprice );
set a;
price=input(x2,8.);
lprice=log(price);
run;
ods graphics on;
proc timeseries data=spprice out=newprice plot=series;
var price lprice;
run;
ods graphics off;
当然还可以看看其描述性统计和简单检验的结果:
proc univariate data=spprice normal plot;
var price lprice;
run;
试图查找价格指数的分布情况
1.各个价格出现比率
proc freq data=spprice ;
table price / noprint out=spfreq(keep=price percent);
run;
2.将比率看做价格出现的概率,试图求出价格的累积分布密度
proc freq data=spprice ;
table price / noprint out=spfreq(keep=price percent);
run;
data _null_;
if 0 then set spfreq nobs=n;
if _n_=1 then call symput('n',compress(put(n,8.0)));
stop;
run;;
data rndprice (keep=price) spcdf(keep=price spprob);
set spfreq end=endofprc;
array prices(&n) prc1-prc&n;
array prob(&n) prb1-prb&n;
retain prc1-prc&n prb1-prb&n;
prices(_n_)=price;
prob(_n_)=percent/100;
if endofprc then do;
spprob=0;
do i=1 to dim(prices);
price=prices(i);
spprob=spprob+prob(i);
output ;
end;
do j=1 to 1000;
price=prices(rantbl(123,of prob(*)));
output ;
end;
end;
run;
proc freq data=rndprice;
table price / noprint out=rndcdf(keep=price percent);
run;
data rndcdf2(keep=price rndprob);
set rndcdf;
retain rndprob 0;
rndprob=rndprob+percent/100;
run;
作出累积分布密度图
data both;
set spcdf(rename=(spprob=prob))
rndcdf2(rename=(rndprob=prob) in=rnd);
retain sample 'theoretical';
if rnd then sample='random';
output;
run;
proc gplot data=both;
plot prob*price=sample;
run;
quit;
http://blog.renren.com/blog/220869953/729348859?from=fanyeNew