zoukankan      html  css  js  c++  java
  • SAS:生成批处理文件(/并行)


    /* 依次处理SAS文件*/
    %MACRO ALL(SASJOB_PATH,SASEXE_PATH,DEAL_NUM);/*参数有三个:文件路径、SAS执行程序路径、要执行的文件数*/
    %LET SASEXE_PATH="&SASEXE_PATH.";
    LIBNAME SASJOB "&SASJOB_PATH";

    DATA _NULL_;
    SET SASJOB.DIRFILES nobs=nobs;
    CALL SYMPUTX('N',nobs);
    STOP;
    RUN;
    %PUT "符合文件类型的文件有:&N." ;

    %MACRO GENERATE_CODE;/*生成批处理文件*/
    %IF &DEAL_NUM.='' %THEN %DO;
    %PUT "请输入要执行的文件个数NUM";%GOTO ENDMACRO;%END;
    %ELSE %IF &DEAL_NUM. > &N. %THEN %DO;
    %PUT "要执行的文件个数超出最大值";%GOTO ENDMACRO;%END;
    %ELSE
    %DO I=1 %TO &DEAL_NUM.;
    filename temp1 "&SASJOB_PATH unsasjob&I..bat" ;
    DATA _NULL_;
    SET SASJOB.DIRFILES;
    IF id=&I.;
    CALL SYMPUTX('NAME1',COMPRESS(NAME_SAS));
    CALL SYMPUTX('NAME2',COMPRESS(NAME_LOG));
    STOP;
    RUN;
    DATA _NULL_;
    FILE temp1;
    PUT " %BQUOTE(&SASEXE_PATH) -SYSIN %STR(%")&SASJOB_PATH&NAME1.%str(%") -LOG %STR(%")&SASJOB_PATH&NAME2.%str(%") " ;
    RUN;
    %END;
    %ENDMACRO:;
    %MEND GENERATE_CODE;
    %GENERATE_CODE;

    %MACRO DEAL_CODE;/*执行批处理文件*/
    %DO I=1 %TO &DEAL_NUM.;
    DATA _NULL_;
    %IF &I.=1 %THEN %DO;
    SYSTASK COMMAND "&SASJOB_PATH unsasjob&I..bat" TASKNAME="job&I" ;
    %END;
    %ELSE %DO;
    WAITFOR job%sysevalf(&I.-1);
    SYSTASK COMMAND "&SASJOB_PATH unsasjob&I..bat" TASKNAME="job&I" ;
    %END;
    RUN;
    %END;
    %MEND DEAL_CODE;
    %DEAL_CODE;

    %MEND;

    %ALL(.,C:Program FilesSASHomeSASFoundation9.4sas.exe,12);

    /*ALL(SASJOB_PATH,SASEXE_PATH,DEAL_NUM)
    SASJOB_PATH 要批处理的文件所在文件夹
    SASEXE_PATH SAS的执行程序所在路径
    N 要执行文件个数
    */

    /*waitfor 的语句主要是限制,SAS执行按顺序依次执行,将waitfor语句去掉可以并行批处理

    SASJOB.DIRFILES是存储要批处理的数据集的名称,如何获取要处理数据集的名称,见“SAS:获取要处理的数据集名称”*/

    Stay hungry, stay foolish
  • 相关阅读:
    CF 852E--Casinos and travel(思维)
    Sigma Sigma Cnk --- CF 575H
    CF1316E-Team Building(dp+贪心)
    cf1316C--Primitive Primes
    cf1323--Count Subrectangles(思维)
    CF252B--鸽巢原理
    HDU3652--容斥+数位dp
    DP--HDU4571(Floyd+dp)
    HDU4219--Randomization?(树形概率DP)
    HDU5945--Fxx and Game dp(单调队列优化)
  • 原文地址:https://www.cnblogs.com/Anni-love-Ferris-wheel/p/6654753.html
Copyright © 2011-2022 走看看