|
楼主的程序偏长。
我照着楼主的公式编写了类似的程序,不知道有没有问题:
options nodate nonotes nosource;
data Raw;
input Population Resource;
cards;
1000 20
2000 40
3000 60
;
proc sql;
create table aa as select Population/sum(Population) as w,Resource/sum(Resource) as y,1/n(Population) as Inverse_n from Raw order by y,w;
quit;
data aa;
set aa;
v+y; *v is the cumulated percentage;
g=w*y+2*w*(1-v)-Inverse_n; *g is the left part of Gini=... equation, ;
run;
proc means data=aa noprint;var g;output out=temp sum=Gini;
data _null_;set temp;put Gini=;run;
|