/����/
    /ginistat/
    Libname loan “d:\2019xyt”;
    %macro ginistat(dsin,probvar,dvvar,dslorenz,m_gini);

    proc sort data=&dsin;
    by &probvar;
    run;

    proc sql noprint;
    select sum(&dvvar) into:nresp from &dsin;
    select count(*) into:nn from &dsin;
    quit;

    /*/
    data &dslorenz;
    set &dsin nobs=nn;
    by &probvar;
    retain tile 1 totresp 0;
    tilesize=ceil(nn/100);
    totresp=totresp+&dvvar;
    totrespPer=totresp/&nresp;
    if _n
    =tile
    tile_size then do;
    output;
    if tile<100 then do
    tile=tile+1;
    sumresp=0;
    end;
    end;
    keep tile totrespPer;
    run;

    data temp;
    tile=0;
    totrespPer=0;
    run;

    data &dslorenz;
    set temp &dslorenz;
    run;

    data &dslorenz;
    set &dslorenz;
    tile=tile/100;
    label totrespPer=”percent of positive”;
    label tile=”percent of population”;
    run;

    /*/
    data null;
    retain xk 0 xk1 0 yk 0 yk1 0 g 1;
    set &dslorenz;
    xk=tile;
    yk=totrespPer;
    g=g-(xk-xk1)
    (yk+yk1);

    xk1=xk;
    tk1=yk;

    call symput(‘g’,compress(g));
    run;

    %let &m_gini=&g;
    proc datasets library=work nodetails nolist;
    delete temp;
    run;quit;
    %mend;

    /��ͼ/
    /**/

    %macro plotlorenz(dslorenz);
    goptions reset=global gunit=pct border cback=white
    colors=(black blue green red)
    ftitle=swissb ftext=swiss htitle=6 htext=4;
    symbol1 color=red interpol=join value=dot height=1;
    proc gplot data=&dslorenz;
    plot totrespPer*tile /haxis=0 to 1 by 0.2 vaxis=0 to 1 by 0.2 hminor=3 vminor=1
    vref=0.2 0.4 0.6 0.8 1.0
    lvref=2 cvref=blue caxis=blue ctext=red;
    run;quit;
    goptions reset=all;
    %mend;

    proc contents data=loan.test_2_fa(drop=v_5) out=a noprint;run;

    proc sql noprint;
    select name into:var separated by ‘ ‘ from a;quit;

    %let varlist=&var.;

    proc logistic data=loan.test_2_fa outest=model_parms;
    model v_5(event=’1’)=&var./selection=stepwise sls=0.05 sle=0.05;
    output out=pred_probs p=pred_v_5;
    run;

    /use the macro/

    %let dsin=pred_probs;
    %let probvar=pred_v_5;
    %let dvvar=v_5;
    %let dslorenz=lorenzds;
    %let gini=;
    %ginistat(&dsin,&probvar,&dvvar,&dslorenz,gini);
    %put >>>>>>>>>>>>>>>>>>>>>>>>> gini=&gini <<<<<<<<<<<<<<<<<<<<<<<<< ;

    %plotlorenz(&dslorenz);