05-23-2016 12:13 PM
I have a table that contains data from 2011 to 2016 that looks like the table posted below. My goal is to predict the number of sales per week in 2017 based on this historical data.
Date Sales 24JUN2011 1 15NOV2011 4 09DEC2011 1 15JAN2012 6 22JAN2012 1 29FEB2012 3
I'm using the following code to plot my sales by day and a LOESS fitted curve to predict future sales:
PROC SGPLOT; SCATTER X=Date Y=Sales; LOESS X=Date Y=Sales /NOMARKERS CLM; RUN;
I'd like to plot sales by week instead of by day, does anyone know the best way of doing so? I tried using the WEEK() function however it returns the week number of the year only without the actual year. Also, any tips on forecasting this type of sales data would be greatly appreciated! I am not sure which method makes the most sense (sales in this industry are somewhat cyclical).
05-23-2016 01:31 PM
Try using a format that combines year and week such as WeekU.
Add this line to the SGPLOT code
Format date weeku5.;
This will show the dates as yyWnn where N is the number of the week in the year.
05-23-2016 10:31 PM
Make a group variable YEAR.
"Also, any tips on forecasting this type of sales data would be greatly appreciated!"
Of course. Your choice is SAS/ETS there are so many PROC to do something forcast . like PROC USM , PROC ARMA ........
data have; input Date : date11. Sales; year=year(date); week=week(date); format Date date9. ; cards; 24JUN2011 1 15NOV2011 4 09DEC2011 1 15JAN2012 6 22JAN2012 1 29FEB2012 3 ; run; PROC SGPLOT; series X=week Y=Sales/markers group=year curvelabel; RUN;