使用BY语句在PROC ARIMA中进行SAS ODS三明治会产生奇怪的结果

时间:2016-08-15 16:02:17

标签: sas export-to-excel ods

我正在尝试将一堆平稳性测试导出到HTML和Excel。使用PROC ARIMA当我尝试将每个部分包裹在“ODS三明治”中时,我会遇到奇怪的行为。看来这是由于在BY var中使用PROC ARIMA命令。如果未使用BY,我会获得预期/期望的ODS输出。

当我CLOSE ODS“三明治”从文件中删除前面的ARIMA输出时,我会尝试将其发送到。它会保存在我打开的后续ODS目的地中。结果是最终ODS 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;

0 个答案:

没有答案