1

我正在尝试将一堆平稳性测试导出到 HTML 和 Excel。当PROC ARIMA我尝试将每个部分包装在“ODS Sandwich”中时,我的行为变得很奇怪。看来这是由于BY varPROC ARIMA. BY不使用时,我得到预期/期望的输出ODS

当我“三明治”时,前面的CLOSE输出会从我尝试将其发送到的文件中删除。相反,它保存在我打开的后续目的地中。结果是最终输出丢失并且每个文件都被错误地命名和定位。ODSARIMAODSODS ARIMA

数据集abc在底部生成。这是对我来说失败的可重现命令。

/*  =========================================== */
/*          PROC ARIMA for Stationarity
                  LEVELS                        */
/*  =========================================== */

ODS _ALL_ CLOSE;

%let pt    = 1;
%let ARpt1 = LEVELS;
ODS graphics on / reset= INDEX imagename="&ARpt1.";

filename X_ADF&pt. "&outDir.&ARIMAdir.ARIMA_ADF_&ARpt1..xlsx" ;
filename H_ADF&pt. "&outDir.&ARIMAdir.ARIMA_ADF_&ARpt1..html" ;
filename g_ADF&pt. "&outDir.&ARIMAdir." ;

ods html  (id=&pt.) file= H_ADF&pt.    gpath = g_ADF&pt.;
ods EXCEL (id=&pt.) file = X_ADF&pt.  
    options(SHEET_INTERVAL="NONE"   /* All tables in one sheet*/
            SHEET_NAME ="LEVELS"
            EMBEDDED_TITLES="YES");

PROC ARIMA data= abc;
    by grp;
 TITLE "ARIMA IDENTIFY - U in levels";

    identify var=  testvar
    stationarity = (adf=(3));
    ods html (id=&pt.)  select StationarityTests SeriesCorrPanel;
    ods EXCEL (id=&pt.) select StationarityTests ;
RUN;

/************************************
   If I include the CLOSE here 
    then the ODS files declared above are empty

*********************************/
ODS _ALL_ CLOSE;


/*  =========================================== */
/*          PROC ARIMA for Stationarity
                    Differences                 */
/*  =========================================== */
%let pt    = 2;
%let ARpt2 = YonY_diff;

ODS graphics on / reset= INDEX imagename="&ARpt2.";

filename X_ADF&pt. "&outDir.&ARIMAdir.ARIMA_ADF_&ARpt2..xlsx" ;
filename H_ADF&pt. "&outDir.&ARIMAdir.ARIMA_ADF_&ARpt2..html" ;
filename g_ADF&pt. "&outDir.&ARIMAdir." ;

ods html  (id=&pt.) file = H_ADF&pt.   gpath = g_ADF&pt.;
ods EXCEL (id=&pt.) file = X_ADF&pt.  
        options(SHEET_INTERVAL="NONE"    /* All tables in one sheet*/
                SHEET_NAME ="Lvl Diff"
                EMBEDDED_TITLES="YES");/* Title Put in EXCEL doc */ 

PROC ARIMA data= abc;
    by grp;
    TITLE "ARIMA IDENTIFY - First Differences by City";

    identify var= testvar(1)    stationarity = (adf=(3));
    ods html  (id=&pt.)         select StationarityTests SeriesCorrPanel;
    ods EXCEL (id=&pt.)         select StationarityTests ;
 RUN;

/************************************
   If I include the CLOSE here 
    then the ODS files (html and excel) declared here
   are filled with the data from the FIRST proc arima 
*********************************/
ODS _ALL_ CLOSE;

谁能告诉它是我的代码有问题,还是有特定问题ARIMA

****数据集 abc 在这里创建****

data a;
 u1 = 0.9; a1 = 0;
 do i = -50 to 100;
    a = rannor( 32565 );
    u = u1 + a - .8 * a1;
    if i > 0 then output;
    a1 = a;
    u1 = u;
 grp = "a";
end;
run;
data b;
 u1 = -0.5; a1 = 0;
    do i = -50 to 100;
       a = rannor( 876196 );
       u = u1 + a - .8 * a1;
       if i > 0 then output;
       a1 = a;
       u1 = u;
     grp = "b";
    end;
run;
data c;
     u1 = 5; a1 = 0.1;
     do i = -50 to 100;
        a = rannor( 876196 );
        u = u1 + a - .8 * a1;
        if i > 0 then output;
        a1 = a;
        u1 = u;
     grp = "c";
    end;
run;
data abc;
   merge a b c;
by grp;
run;
4

1 回答 1

1

问题确实QUIT;是使用按组处理时的位置。这是因为RUN;当您使用按组处理时,它不会做任何事情(因为 SAS 更愿意在执行任何操作之前了解您想要为每个 BY 组做的所有事情)。因此ODS HTML CLOSE;,当您认为它们执行时,您的等不会执行。

这是一个显示此问题的令牌示例。尝试在没有 QUIT 注释的情况下运行;然后用它,看看有什么不同。

   title1 'Simulated IMA(1,1) Series';
   data a;
     dummy=1;
     u1 = 0.9; a1 = 0;
     do i = -50 to 100;
        a = rannor( 32565 );
        u= u1 + a - .8 * a1;
        if i > 0 then output;
        a1 = a;
        u1 = u;
     end;
   run; 


   ods html3 file="c:\temp\test.html";
   ods excel file="c:\temp\test.xlsx";
   proc arima data=a;
     by dummy;
     identify var=u;
     ods html3 select DescStats;
     ods excel select  SeriesCorrPanel;
     run;
     *quit;
  ods html3 close;
  ods excel close;

  *Here I put them out to a different file to make more obvious what is happening;
  ods html3 file="c:\temp\test1.html";
  ods excel file="c:\temp\test1.xlsx";
  proc arima data=a;
    by dummy;
     ods html3 select DescStats;
     ods excel select  SeriesCorrPanel;
     identify var=u(1);
     run;
    *quit;
  ods html3 close;
  ods excel close;
quit;
于 2016-08-15T18:36:14.427 回答