zoukankan      html  css  js  c++  java
  • SAS 评分卡开发模型变量统计及输出

    以下代码实现功能:

    1、获取10个模型分别使用哪些变量

    2、变量所模型使用的次数

    3、把上表格输出到EXCEL中


    %INCLUDE '00@HEADER.SAS';

    %let dir=..4@Model;

    libname cc "&dir";

    PROC FORMAT;
    VALUE UseFmt
    1='使用'
    0='未使用'
    OTHER='其它'
    ;
    RUN;

    PROC DATASETS LIBRARY=S NODETAILS NOLIST;
    DELETE ModelVariableList VarFreq;
    RUN;

    %MACRO FreqAppend(DSIN,FN);

    PROC FREQ DATA=&DSIN;
    TABLES &FN/MISSING NOPRINT OUT=A;
    RUN;

    DATA B;
    LENGTH FName $32. VAL $200.;
    SET A;
    VAL=&FN.;
    FName="&FN.";
    DROP &FN.;
    RUN;

    PROC APPEND BASE=S.VarFreq DATA=B;

    RUN;
    %MEND;

    %MACRO ModelVariable;

    %DO SM=0 %TO 99;
    DATA A;
    LENGTH ModelOrder $3.;
    SET CC.model_params&SM;
    ModelOrder="&SM.";
    RUN;
    PROC APPEND BASE=S.ModelVariableList DATA=A;
    RUN;
    %END;


    DATA S.ModelVariableList;
    SET S.ModelVariableList;
    ARRAY NUM{*} _NUMERIC_;
    DO I=1 TO DIM(NUM);
    IF MISSING(NUM{I}) THEN NUM{I}=0;
    ELSE NUM{I}=1;
    END;
    KEEP ModelOrder X1_WOE X2_WOE X3_WOE X4_WOE X5_WOE B1_WOE S1_WOE;
    RUN;
    %MEND;

    %ModelVariable;

    DATA _NULL_;
    DO V='X1_WOE','X2_WOE','X3_WOE','X4_WOE','X5_WOE','B1_WOE','S1_WOE';
    CALL EXECUTE('%FreqAppend(S.ModelVariableList,'||V||')');
    END;
    RUN;

    PROC PRINT DATA=S.VarFreq;
    RUN;

    PROC SORT DATA=S.VarFreq OUT=A1(DROP=PERCENT);
    BY FName;
    RUN;


    PROC TRANSPOSE DATA=A1 OUT=A2(DROP=_NAME_);
    BY FName;
    RUN;

    DATA A2;
    SET A2;
    IF MISSING(COL2) THEN COL2=0;
    RUN;

    ODS TAGSETS.EXCELXP FILE='ModelVariableList.XLSX';

    PROC PRINT DATA=S.ModelVariableList LABEL;
    VAR ModelOrder X1_WOE X2_WOE X3_WOE X4_WOE X5_WOE B1_WOE S1_WOE;
    FORMAT X1_WOE X2_WOE X3_WOE X4_WOE X5_WOE B1_WOE S1_WOE UseFmt.;
    LABEL ModelOrder='模型号';
    RUN;

    PROC SORT DATA=A2;
    BY DESCENDING COL1;
    RUN;

    PROC PRINT DATA=A2 LABEL;
    LABEL FName='变量' COL1='进入模型次数' COL2='未进入模型次数';
    VAR FName COL1 COL2;
    RUN;

    ODS TAGSETS.EXCELXP CLOSE;

  • 相关阅读:
    destroy-method="close"
    2.2 Spring的结构组成--Spring源码深度解析
    2.1 Spring容器的基本实现--Spring源码深度解析
    1.2 Spring环境搭建--Spring源码深度解析
    1.1 Spring的整体架构--Spring源码深度解析
    迟到的2016年计划
    spring学习 之helloworld
    从零实现DNN 探究梯度下降的原理
    Java注解——这些@圈圈都是个啥?
    自动发送日报,骗过你的领导^-^
  • 原文地址:https://www.cnblogs.com/wdkshy/p/10000100.html
Copyright © 2011-2022 走看看