/����ͼ�ļ��������/
    /���������߼���/
    %macro liftchart(dsin,probvar,dvvar,dslift);

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

    %local p ntot;
    proc sql noprint;
    select sum(&dvvar) into:p from &dsin;
    select count(*) into:ntot from &dsin;
    quit;

    %let n=%eval(&ntot-&p);/total negative(good)/

    data &dslift;
    set &dsin nobs=nn;
    by descending &probvar;
    retain tile 1 sump 0 totp 0 sumn 0 totn 0;
    tile_size=ceil(nn/10);
    tileper=tile/10;

    label tileper=”percent of population”;
    label tilep=”percent of population”;

    if &dvvar=1 then sump=sump+&dvvar;
    else sumn=sumn+1;

    pper=sump/&p;
    /positive %/
    nper=sumn/&n;
    /negative %/

    label pper=”percent of positive”;
    label nper=”percent of negative”;

    if n=tile*tile_size then do;
    output;
    if tile<10 then tile=tile+1;
    end;
    keep tileper pper nper;
    run;

    data temp;
    tileper=0;
    pper=0;
    nper=0;
    run;

    data &dslift;
    set temp &dslift;
    run;

    %mend;

    /��ͼ/
    %macro plotlift(dslift);
    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=3;
    proc gplot data=&dslift;
    plot pper*tileper /haxis=0 to 1 by 0.1 vaxis=0 to 1 by 0.1 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;

    libname loan “D:\2019XYT”;
    proc contents data=loan.bpractice_2_fa(drop=v_5) out=a;run;

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

    %let varlist=&var.;

    proc logistic data=loan.bpractice_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 dslift=liftchartds;
    %liftchart(&dsin,&probvar,&dvvar,&dslift);

    proc print data=&dslift;
    run;

    %plotlift(&dslift);