导航

SAS 删除数据和对缺失值处理代码程序

Posted on 2018-11-21 17:34  高山老王  阅读(2962)  评论(0编辑  收藏  举报

 

%INCLUDE '00@HEADER.SAS';

%LET dir=..\04@Model;
LIBNAME cc "&dir";

%MACRO ModelVariable;

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

%DO SM=0 %TO 9;
PROC APPEND BASE=S.ModelVariableList DATA=CC.model_params&SM;
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 X1_WOE X2_WOE X3_WOE X4_WOE X5_WOE B1_WOE S1_WOE;
RUN;

PROC FREQ;
TABLES _ALL_/MISSING;
RUN;

ODS TAGSETS.EXCELXP FILE='ModelVariableList.XLSX';
PROC PRINT DATA=S.ModelVariableList;
RUN;
ODS _ALL_ CLOSE;

%MEND;

%ModelVariable;