BookmarkSubscribeRSS Feed
Hadrien
Obsidian | Level 7

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

2 REPLIES 2
ballardw
Super User

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.

Ksharp
Super User

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;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 2088 views
  • 0 likes
  • 3 in conversation