SAS spec_reader宏

%macro spec_reader(data);

data spec;
SET SPEC."&data.$"n;
run;

data spec1;
    set spec;
    where upcase(Domain) ne "DOMAIN" and variable_name ne " ";
run;

data temp;
    set spec1;
    length long $100;
    if upcase(type)="TEXT" then long="$"||length;
     if upcase(type)="INTEGER"  then long="8";
    if upcase(type)="FLOAT"  then long="8";
    if upcase(type)="DATE" or upcase(type)="DATETIME"  then long="$"||length;
run;

data spec2;
    set temp end=eof;
    call symput("attrib"||strip(put(_N_,3.)),"_"||Variable_Name||" "||"length="||strip(long)||" "||"label="||'"'||strip(Variable_Label)||'"');
    if eof then call symput("sum",strip(put(_n_,3.)));
run;


data &data._temp;
    attrib
    %do j=1 %to ∑
        &&attrib&j
    %end;
    ;
    call missing (of _All_);
    if 0;
run;

%mend;

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务