BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
lizzy28
Quartz | Level 8

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?

1 ACCEPTED SOLUTION

Accepted Solutions
alexchien
Pyrite | Level 9

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

2 REPLIES 2
Reeza
Super User

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

 

 

 

alexchien
Pyrite | Level 9

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

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