## How do I plot my time series scatterplot by week and predict future values?

Occasional Contributor
Posts: 15

# How do I plot my time series scatterplot by week and predict future values?

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).

Thanks

Super User
Posts: 13,583

## Re: How do I plot my time series scatterplot by week and predict future values?

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.

Super User
Posts: 10,787

## Re: How do I plot my time series scatterplot by week and predict future values?

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;``````
Discussion stats
• 2 replies
• 337 views
• 0 likes
• 3 in conversation