安装是安装好了,但是web去调用我写好的.sas 文件,还是没有搞通啊。
求大神指导了。
首先附上我的代码:
/*定义变量*/
%let test=sasuser.dis_2;
/*原始数据*/
data prepare;
set &test;
p1=overtime/flytime;
keep workage p1;
run;
/*为使聚类结果从小到达排序,按照工龄,千次率进行排序*/
proc sort data=prepare out=prepare_S;
by workage p1;
run;
/*按照工龄进行聚类分析*/
proc fastclus data=prepare_S maxc=3 out=cluster_1 mean=m1 cluster=come list distance replace=none noprint;
var p1;
id workage;
by workage;
run;
/*区分类中心及各个千次率*/
data cluster_c;
set cluster_1;
rate=p1;
drop p1;
run;
data cm;
merge cluster_c m1;
by workage come;
run;
%macro countcycle;
%do i=1 %to 20;
data m2;
set cm;
overrate=rate;
w1=workage;
w2=workage**2;
w3=workage**3;
run;
proc sort data=m2 out=m2_S ;
by come workage;
run;
proc sql noprint;
select max(p1)+0.1,max(workage)+1 into :maxrate,:maxage from m2_S ;
quit;
proc reg data=m2_S outest=m2_R noprint;
by come;
model p1=w1 w2 w3;
run;
data m2_t;
set m2_S;
drop w1 w2 w3;
run;
/*图1*/
data m2_f;
merge m2_R m2_t;
by come;
clustercls=come;
regscore=workage**3*w3+workage**2*w2+workage*w1+Intercept;
run;
proc sort data=m2_f out=m2_f1;
by workage;
run;
data score1;
set m2_f1(where = (come=1) );
score1=regscore;
keep workage score1;
run;
proc sort noduprecs data=score1 out=score1_s;
by workage;
run;
data score2;
set m2_f1(where = (come=2) );
score2=regscore;
keep workage score2;
run;
proc sort noduprecs data=score2 out=score2_s;
by workage;
run;
data score3;
set m2_f1(where = (come=3) );
score3=regscore;
keep workage score3;
run;
proc sort noduprecs data=score3 out=score3_s;
by workage;
run;
data score_all;
merge score1_s score2_s score3_s m2_f1;
rate_1=abs(rate-score1);
rate_2=abs(rate-score2);
rate_3=abs(rate-score3);
by workage;
run;
proc sort data=score_all out=score_all_s;
by come;
run;
data a116;
set score_all_s;
comeold=come;
by come;
if min(rate_1,rate_2,rate_3)=rate_1 then come=1;
if min(rate_1,rate_2,rate_3)=rate_2 then come=2;
if min(rate_1,rate_2,rate_3)=rate_3 then come=3;
keep workage come comeold rate p1 clustercls regscore;
run;
proc sort data=a116 out=cm;
by workage come;
run;
%end;
%mend;
%countcycle;
proc sql noprint;
create table total as
select come,count(*) as total from work.all
quit;
proc summary data=total nway missing noprint;
class come total;
output out=ts;
run;
proc sql noprint;
create table prop as
select come,_FREQ_/total as prop from ts;
quit;
data prop_show;
set prop;
if come=1 then call symput("_1",trim(left(put(prop,percent12.2))));
if come=2 then call symput("_2",trim(left(put(prop,percent12.2))));
if come=3 then call symput("_3",trim(left(put(prop,percent12.2))));
run;
footnote1 h=12pt c=green " 1-(第1类飞行员为&_1) " c=blue " 2-(第2类飞行员为&_2) " c=red " 3-(第3类飞行员为&_3) " ;
proc sort data=cm out=all;
by workage clustercls;
/*关闭当前的ODS输出*/
ods listing close;
/*指定新的ODS输出*/
ods html body=_webout
stylesheet="http://10.10.179.24/fss/css/sasstyle.css"
headtext="<script language='Javascript' src='http://10.10.179.24/fss/js/sasinstallgra7phic.js'></script>"
rs=none;
/*指定X周刻度*/
axis1 order = 1 to &maxage by 1 label=("工龄");
/*指定Y周刻度*/
axis2 order = 0 to &maxrate by 0.1 label=("千次率");
symbol1 cv=green interpol=none
width=1 value=dot
height=1;
symbol2 cv=blue interpol=none
width=1 value=dot
height=1;
symbol3 cv=red interpol=none
width=1 value=dot
height=1;
symbol4 ci=green interpol=spline
width=2 height=2;
symbol5 ci=blue interpol=spline
width=2 height=2;
symbol6 ci=red interpol=spline
width=2 height=2;
legend1 label=('聚类');
proc gplot data=all;
plot rate*workage=clustercls / vaxis=axis2 vminor=0 haxis=axis1 vminor=0 legend=legend1 ;
plot2 regscore*workage=clustercls/ vaxis=axis2 vminor=1 NOAXIS NOLEGEND ;
title height=4 "飞行员飞行品质分类评估";
run;
quit;
以上内容中有问题的部分应该是以下这段:
/*关闭当前的ODS输出*/
ods listing close;
/*指定新的ODS输出*/
ods html body=_webout
stylesheet="http://10.10.179.24/fss/css/sasstyle.css"
headtext="<script language='Javascript' src='http://10.10.179.24/fss/js/sasinstallgra7phic.js'></script>"
rs=none;
把这一段全掉,我的代码是能够在sas里面直接运行出图的如下:
最后是数据集
all.xls
(38.5 KB)