我試圖將一羣平穩性測試導出到HTML和Excel。 PROC ARIMA
當我嘗試在「ODS三明治」中包裝每個部件時,我會收到奇怪的行爲。看起來這是由於在PROC ARIMA
中使用BY var
命令。當BY
未被使用時,我得到預期/期望的ODS
輸出。SAS ODS三明治在PROC ARIMA中用BY語句生成奇怪的結果
當我I 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
特定問題?
**** DATA SET ABC CREATED該處 ****
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;
我不知道,如果你有一個事實,即'PROC ARIMA'是互動(運行組),需要一個'退出的問題;',雖然我沒有看到明顯的聯繫(RUN應該引起輸出對象被創建,並且在快速測試中,它看起來像我期望的那樣以及您的程序期望它的行爲)。我建議創建一個更簡單的例子 - 一個使用可模擬數據的例子,以便我們可以在我們這邊看到它 - 並以這種方式複製問題。 – Joe
您可以使用http://support.sas.com/documentation/cdl/en/etsug/60372/HTML/default/viewer.htm#etsug_arima_sect055.htm作爲基本示例,因爲它可供我們隨時使用。這就是我在我的示例測試中使用的,它可以像您期望的那樣產生輸出。 – Joe
謝謝@Joe--這幫助我將問題隔離到'BY'語句。這個問題似乎只在我按小組做'ARIMA'時纔會出現。我已經更新了這方面的問題,幷包含了一些從該示例測試中改編的可重複數據。 –