我希望我能在正确的地方提出这个问题: 我想要预测一些与时间相关的事件,以便它们是一致的。有人可以解释一下如何在SAS中做到这一点吗?
我在SAS工作,而且我已经尝试过对此进行研究,但对我来说,矩阵代数真的很可怕(我尝试了类似于同期等级的游戏 - 理论上的最佳和解)时间序列预测')。我只是一个凡人,我不知道如何将这些公式纳入我的SAS编码。
此问题的示例来自' sashelp.citiday'。 如果我创建一个数据集,根据时间运行一些独立的预测,它们就不能累加到总数。我真的希望他们加起来。我怎样才能做到这一点?
谢谢!
以下代码:
data temp;
set sashelp.citiday;
format WeekDay $9.;
/* Simplify some variables */
count1=round(SNYDJCM,1);
count2=round(SNYSECM,1);
count3=round(DFXWUK90,1);
/* Create a 'Total' column */
total=sum (of count1-count3);
/* create weekday */
day=datdif("1jan1988"d,date,'actual');
if day=1 then weekday="Friday";
if day=2 then weekday="Saturday";
if day=3 then weekday="Sunday";
if day=4 then weekday="Monday";
if day=5 then weekday="Tuesday";
if day=6 then weekday="Wednesday";
if day=7 then weekday="Thursday";
if weekday=. then do;
if round(day/7)=day/7 then weekday="Thursday";
else if round((day-1)/7)=(day-1)/7 then weekday="Friday";
else if round((day-2)/7)=(day-2)/7 then weekday="Saturday";
else if round((day-3)/7)=(day-3)/7 then weekday="Sunday";
else if round((day-4)/7)=(day-4)/7 then weekday="Monday";
else if round((day-5)/7)=(day-5)/7 then weekday="Tuesday";
else if round((day-6)/7)=(day-6)/7 then weekday="Wednesday";
end;
/* Create Month */
Month=month(date);
keep date count1-count3 total day weekday month;
run;
%macro prediction(indata,outcome,predlab,outdata);
proc hpgenselect data=&indata.;
class weekday month;
model &outcome.=day weekday month weekday*month day*day /dist=nb ;
selection method=backward (choose=aic) hierarchy=single details=all ;
output out=&outdata. p=&predlab.;
run;
%mend prediction;
%prediction(temp,count1,pred1,forecast);
%prediction(forecast,count2,pred2,forecast);
%prediction(forecast,count3,pred3,forecast);
%prediction(forecast,total,predT,forecast);
data forecast;
set forecast;
sumpred=sum(of pred1-pred3);
diff=sumpred-predT;
run;