-
Notifications
You must be signed in to change notification settings - Fork 199
/
Copy pathchpt8.sas
105 lines (98 loc) · 4.54 KB
/
chpt8.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
*-------------------------------------------------------------------*/
/* SAS FOR FORECASTING TIME SERIES, SECOND EDITION */
/* by John C. Brocklebank and David A. Dickey */
/* Copyright(c) 2003 by SAS Institute Inc., Cary, NC, USA */
/* SAS Publications order # 57275 */
/* Jointly co-published by SAS Institute and John Wiley & Sons 2003 */
/* SAS ISBN 1-59047-182-2 */
John Wiley & Sons, Inc. ISBN 0-471-39566-8 */
/*-------------------------------------------------------------------*/
/* */
/* This material is provided "as is" by SAS Institute Inc. There */
/* are no warranties, expressed or implied, as to merchantability or */
/* fitness for a particular purpose regarding the materials or code */
/* contained herein. The Institute is not responsible for errors */
/* in this material as it now exists or will exist, nor does the */
/* Institute provide technical support for it. */
/* */
/*-------------------------------------------------------------------*/
/* Questions or problem reports concerning this material may be */
/* addressed to the author: */
/* */
/* SAS Institute Inc. */
/* Books by Users */
/* Attn: John Brocklebank and David Dickey */
/* SAS Campus Drive */
/* Cary, NC 27513 */
/* */
/* */
/* If you prefer, you can send email to: [email protected] */
/* Use this for subject field: */
/* Comments for John Brocklebank and David Dickey */
/* */
/*-------------------------------------------------------------------*/
Chapter 8 - Data Mining and Forecasting
proc hpf data=vc_data.daily_stats_09aug02 outfor=forecasts lead=7 print=all;
id date interval=day;
forecast revenue;
run;
symbol1 v = none i = join l = 1 c = black
height=.5 width=.5;
symbol2 v = = i = join l = 2 c = green
height=.5 width=.5;
symbol3 v = none i = join l = 1 c = red
height=.5 width=.5;
proc gplot data=forecasts;
plot actual*date = 1
predict*date = 2
lower*date = 3
upper*date = 3 / overlay
hminor = 0
vminor = 0
caxis = black
frame ;
title h=2 c=black f=swissb 'The Vermont Country Store Revenue';
format actual dollar15.2;
run;
quit;
proc autoreg data=vc_data.daily_stats_09aug02;
model revenue=buyer dollars_per_purch_session
/*perc_abandon_carts*/ productsuggestion_pages
/*new_buy_perc*/
/nlag=8 backstep slstay=.15 method=ml;
run;
proc model data=vc_data.daily_stats_09aug02 outmodel=outmodel;
revenue = b0 + b1*buyer + b2*dollars_per_purch_session +
b3*productsuggestion_pages ;
%ar(revenue,7,,1 5 7);
fit revenue / outest=outest maxiter=1000
method=marquardt;
run;
data goal goal2;
set vc_data.daily_stats_09aug02(where=(date='09aug02'd) keep=
revenue buyer dollars_per_purch_session productsuggestion_pages
date);
output goal;
revenue = round(1.05*revenue); /* 5% increase */
output goal2;
run;
proc model model=outmodel;
solve buyer / estdata=outest data=goal2
out=outsolve1;
solve dollars_per_purch_session / estdata=outest data=goal2
out=outsolve2;
solve productsuggestion_pages / estdata=outest data=goal2
out=outsolve3;
run;
data solve;
set goal(in=goal) outsolve1(in=outsolve1) outsolve2(in=outsolve2)
outsolve3(in=outsolve3) ;
length type $ 31;
if goal then type='';
else if outsolve1 then type='Purchasing Sessions Solve';
else if outsolve2 then type='Average Order Value Solve';
else if outsolve3 then type='Product Suggestion Pages Solve';
run;
proc print data=solve;
format productsuggestion_pages 7.2;
run;