Modeling Long Seasonal Patterns
/*--------------------------------------------------------------
SAS Sample Library
Name: ucmex03.sas
Description: Example program from SAS/ETS User's Guide,
The UCM Procedure
Title: Modeling Long Seasonal Patterns
Product: SAS/ETS Software
Keys: equally spaced univariate time series data
PROC: UCM
Notes:
--------------------------------------------------------------*/
data callCenter;
input calls @@;
label calls= "Number of Calls Received in a 6 Hour Shift";
start = '15dec99:00:00'dt;
datetime = INTNX( 'dthour6', start, _n_-1 );
format datetime datetime10.;
datalines;
18 122 244 128 19 113 230 119 17 112
219 93 14 73 139 53 11 32 74 56
15 137 289 153 20 125 227 106 16 101
201 92 14 94 187 69 11 59 94 21
4 7 13 11 4 17 45 39 10 118
291 147 19 130 246 109 15 112 217 93
15 103 202 77 13 73 129 24 4 14
42 29 8 22 66 64 14 141 320 173
21 132 260 124 17 104 218 108 16 97
198 99 14 91 193 75 10 60 124 50
9 27 72 60 14 125 306 177 20 125
261 141 17 111 226 121 15 98 218 120
16 106 222 93 12 66 140 54 10 28
70 51 12 104 196 91 14 107 288 196
21 132 255 131 16 102 229 119 15 102
213 84 12 65 131 51 10 29 76 58
13 121 284 166 19 118 234 116 15 102
218 112 15 95 204 109 14 98 202 86
11 66 135 55 10 29 77 46 14 125
306 180 21 133 269 148 18 123 236 121
16 106 211 108 15 103 200 79 11 66
120 49 9 29 72 58 14 126 260 139
16 113 219 120 15 105 210 115 15 104
218 123 15 107 212 89 12 70 135 56
10 30 77 58 14 125 305 177 19 138
262 138 17 116 229 124 17 108 221 120
15 107 223 88 11 68 131 54 10 31
71 53 12 112 189 90 13 113 268 173
19 124 217 113 15 99 204 107 13 100
196 85 11 66 121 51 9 30 72 59
13 125 270 153 17 121 219 120 17 113
218 119 16 112 216 116 16 112 201 78
10 69 106 45 9 30 66 57 13 129
236 123 15 107 191 101 14 101 202 112
14 103 206 119 15 108 203 85 11 70
126 53 9 33 73 55 12 138 295 177
18 136 245 136 17 124 221 116 14 107
206 112 15 104 203 80 11 71 126 53
9 32 72 57 12 137 293 168 17 122
229 122 14 108 201 108 13 98 186 103
14 98 176 73 10 65 111 47 8 32
63 47 11 122 264 154 16 119 212 116
14 106 196 106 13 101 190 105 14 107
192 80 11 72 114 49 8 23 72 64
17 123 283 164 23 110 215 117 17 94
183 96 16 86 167 89 14 85 172 73
11 56 110 50 10 28 71 58 14 126
279 173 20 116 233 133 17 106 207 114
16 97 202 118 16 104 208 97 13 66
129 59 11 31 70 61 16 139 311 181
20 126 238 131 16 108 210 112 15 102
209 107 14 103 197 78 10 54 110 48
10 17 38 41 12 136 295 172 20 127
236 125 16 108 207 112 15 98 200 113
15 104 205 89 12 68 116 54 10 30
66 61
;
ods output PostSamplePrediction = Post1 (
rename = (predict=Forecast time=datetime) drop=_group_ SSE);
proc ucm data=callCenter;
id datetime interval=dthour6;
model calls;
irregular;
level;
season length=28 type=trig
print=(harmonics);
estimate back=28;
forecast back=28 lead=28;
run;
proc print data=post1 noobs;
format _numeric_ 8.3;
format datetime datetime10.;
format obs actual 8.0;
run;
ods output PostSamplePrediction = Post2 (where=(Obs = 552)
rename = (predict=Forecast time=datetime) drop=_group_ SSE);
proc ucm data=callCenter;
id datetime interval=dthour6;
model calls;
irregular;
level;
season length=28 type=trig droph=12 13 14;
estimate back=28;
forecast back=28 lead=28;
run;
proc print data=post2 noobs;
format _numeric_ 8.3;
format datetime datetime10.;
format obs actual 8.0;
run;
ods output PostSamplePrediction = Post3 (where=(Obs = 552)
rename = (predict=Forecast time=datetime) drop=_group_ SSE);
proc ucm data=callCenter;
id datetime interval=dthour6;
model calls;
irregular;
level;
splineseason length=28
knots=3 5 7 9 11 13 15 17 19 21 23 25 27
degree=3;
estimate back=28;
forecast back=28 lead=28;
run;
proc print data=post3 noobs;
format _numeric_ 8.3;
format datetime datetime10.;
format obs actual 8.0;
run;
ods output PostSamplePrediction = Post4 (where=(Obs = 552)
rename = (predict=Forecast time=datetime) drop=_group_ SSE);
proc ucm data=callCenter;
id datetime interval=dthour6;
model calls;
irregular;
level;
season length=4 type=trig;
blockseason nblocks=7 blocksize=4
type=trig;
estimate back=28;
forecast back=28 lead=28;
nloptions tech=dbldog;
run;
proc print data=post4 noobs;
format _numeric_ 8.3;
format datetime datetime10.;
format obs actual 8.0;
run;