Forecasting using SAS Forecast Server, SAS/ETS, and more

How to make forecast for the time series data with regular date gaps

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 98
Accepted Solution

How to make forecast for the time series data with regular date gaps

Hi everyone,

 

I'm trying to make my question simple. My sales data have value of zero, meaning that there is no sales occurring at all, say, on Sundays. Therefore, the date is continuous since I do not need to forecast for Sunday sales. Is there any way to make forecast for such a time series data with the date gap?


Accepted Solutions
Solution
‎02-11-2016 11:47 AM
SAS Super FREQ
Posts: 93

Re: How to make forecast for the time series data with regular date gaps

If there is no sales on Sunday, filter Sunday's data out of the input, and use ID INTERVAL = WEEKDAY1W. The default seasonality for WEEKDAY1W is 6 (Monday to Saturday, the 1 in the interval stands for Sunday). If the data only consists of Monday to Friday's sales, use INTERVAL = WEEKDAY16W (1 for Sunday and 6 for Saturday).

 

Here is a sample code to use INTERVAL = WEEKDAY1W:

 

/*generate test data with sales from Monday to Saturday only*/

data test;
    format date date7.;
    starting_date = mdy(1,31,2016);
    do i =0 to 700;
        date = starting_date + i;
        if mod(i,7) ne 0 then do;
            sales = abs(100*rannor(12345));
            output;
        end;
    end;
    drop i starting_date;
run;

 

/*use WEEKDAY1W interval to handle 6 days a week data*/

proc hpf data = test seasonality = 6 out= _null_ outfor = outfor;
    id date interval=weekday1w;
    forecast sales;
run;

View solution in original post


All Replies
Super User
Posts: 19,771

Re: How to make forecast for the time series data with regular date gaps

I'm not familiar with the SAS time series procs, but could you generate a consecutive series with a different variable representing 'time' so that it appears as if Monday follows Saturday.  Complete the analysis and then move back to using dates. If it requires a date variable this won't work.

 

ie

Current_Var New_Var
Monday      1
Tuesday     2
Wednesday   3
Thursday    4
Friday      5
Saturday    6
Monday      7
Tuesday     8

 

 

 

Solution
‎02-11-2016 11:47 AM
SAS Super FREQ
Posts: 93

Re: How to make forecast for the time series data with regular date gaps

If there is no sales on Sunday, filter Sunday's data out of the input, and use ID INTERVAL = WEEKDAY1W. The default seasonality for WEEKDAY1W is 6 (Monday to Saturday, the 1 in the interval stands for Sunday). If the data only consists of Monday to Friday's sales, use INTERVAL = WEEKDAY16W (1 for Sunday and 6 for Saturday).

 

Here is a sample code to use INTERVAL = WEEKDAY1W:

 

/*generate test data with sales from Monday to Saturday only*/

data test;
    format date date7.;
    starting_date = mdy(1,31,2016);
    do i =0 to 700;
        date = starting_date + i;
        if mod(i,7) ne 0 then do;
            sales = abs(100*rannor(12345));
            output;
        end;
    end;
    drop i starting_date;
run;

 

/*use WEEKDAY1W interval to handle 6 days a week data*/

proc hpf data = test seasonality = 6 out= _null_ outfor = outfor;
    id date interval=weekday1w;
    forecast sales;
run;

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 411 views
  • 3 likes
  • 3 in conversation