美文网首页
批量导入excel

批量导入excel

作者: 寒微123 | 来源:发表于2018-10-30 14:14 被阅读0次

    %let dirname = E:\CampaignRpt\biocam\leif\201810;
    filename dirlist pipe "dir /B &dirname*.xlsx";

    data dirlist_leif ;
    length fname 2560; infile dirlist length=reclen; input fnamevarying2560. reclen;
    run;

    data dirlist_leif;
    set dirlist_leif;
    call symput ('pvars',n);
    run;

    %put &pvars.;

    data leif ;
    format Campaign_code 50. Customer_ID50.
    Group_Code 50. Senddate50.
    SMS_Code 50. EDM_Code50.
    Email_Address 200. SMS_Sending_Status50.
    SMS_Sending_Time 200. SMS_Reply50.
    Email_Sending_Status 50. Email_Open_Status50.
    Email_Click_Status 50. Email_Sending_Time200.
    Order_Time 50. Order_Revenue50. ;
    /varname $40./

    stop;
    run;

    %macro getxlsx;
    %do i=1 %to &pvars.;
    data null;
    set dirlist_leif;
    if n=&i.;
    call symput ('file',trim(fname));
    run;
    %put &file. ;

    PROC IMPORT OUT= IMPORT
    DATAFILE= "&dirname&file."
    DBMS=EXCEL REPLACE;
    SHEET="Sheet1$";
    GETNAMES=YES;
    MIXED=YES;
    SCANTEXT=YES;

    RUN;

    data leif;
    set leif
    IMPORT
    ;
    run;

    %end;
    %mend;

    %getxlsx;

    相关文章

      网友评论

          本文标题:批量导入excel

          本文链接:https://www.haomeiwen.com/subject/ccdgtqtx.html