Building Monthly GDP
/*--------------------------------------------------------------
SAS Sample Library
Name: ssmex16.sas
Description: Example program from SAS/ETS User's Guide,
The SSM Procedure
Title: Building Monthly GDP
Product: SAS/ETS Software
Keys: Multivariate Modeling, Temporal Distribution
PROC: SSM
Notes:
--------------------------------------------------------------*/
data useco;
input startQ gdp indpro;
date = intnx('month','01jan1947'd, _n_-1);
format date date.;
datalines;
1 . 13.6351
0 . 13.7156
0 19.34471 13.7962
1 . 13.6888
0 . 13.7425
0 19.32281 13.7425
1 . 13.6619
0 . 13.7425
0 19.30315 13.8498
1 . 13.984
0 . 14.1719
0 19.60705 14.2256
1 . 14.3061
0 . 14.333
0 19.89535 14.1719
1 . 14.1988
0 . 14.4403
0 20.21851 14.6282
1 . 14.6282
0 . 14.5745
0 20.33155 14.4672
1 . 14.5745
0 . 14.3867
0 20.35329 14.2524
1 . 14.1182
0 . 13.984
0 20.07522 13.7156
1 . 13.6351
0 . 13.4472
0 20.00788 13.4204
1 . 13.3935
0 . 13.5277
0 20.22798 13.662
1 . 13.152
0 . 13.5009
0 20.04653 13.7425
1 . 13.984
0 . 14.0377
0 20.84559 14.494
1 . 14.9771
0 . 15.3261
0 21.47592 15.7824
1 . 16.2923
0 . 16.8023
0 22.30362 16.695
1 . 16.8023
0 . 16.7755
0 22.73435 17.0707
1 . 17.1244
0 . 17.2318
0 23.04542 17.3123
1 . 17.3391
0 . 17.2855
0 23.44517 17.2049
1 . 16.9365
0 . 16.7755
0 23.92808 16.8828
1 . 16.856
0 . 16.9902
0 23.98105 17.0976
1 . 17.2854
0 . 17.3928
0 24.23457 17.4465
1 . 17.2854
0 . 17.1244
0 24.28516 16.9634
1 . 16.6949
0 . 17.7686
0 24.46081 18.4128
1 . 18.6007
0 . 18.9764
0 25.26359 19.0838
1 . 19.1375
0 . 19.2448
0 25.73372 19.4059
1 . 19.4864
0 . 19.5938
0 25.93456 19.5132
1 . 19.7548
0 . 19.6474
0 25.78922 19.2448
1 . 19.0838
0 . 18.6275
0 25.39786 18.1712
1 . 18.037
0 . 18.0907
0 25.28043 17.9833
1 . 17.8759
0 . 17.9833
0 25.30689 18.037
1 . 18.0638
0 . 18.037
0 25.59397 18.0638
1 . 18.2786
0 . 18.5738
0 26.09272 18.8154
1 . 19.2448
0 . 19.4864
0 26.83766 19.9427
1 . 20.1843
0 . 20.5063
0 27.27452 20.5332
1 . 20.6942
0 . 20.6674
0 27.64128 20.8016
1 . 21.1505
0 . 21.2042
0 27.80762 21.2847
1 . 21.4189
0 . 21.2311
0 27.70032 21.2311
1 . 21.3921
0 . 21.2042
0 27.92872 21.0163
1 . 20.3721
0 . 21.2042
0 27.90588 21.6873
1 . 21.8752
0 . 21.6873
0 28.36238 22.0094
1 . 21.9289
0 . 22.1437
0 28.54517 22.1168
1 . 21.8215
0 . 21.741
0 28.48186 21.7947
1 . 21.9289
0 . 21.9289
0 28.75927 21.741
1 . 21.4189
0 . 20.909
0 28.46446 20.5063
1 . 20.1306
0 . 19.7011
0 27.72654 19.4596
1 . 19.1375
0 . 19.3253
0 27.90948 19.8353
1 . 20.1306
0 . 20.5332
0 28.55472 20.7211
1 . 20.9626
0 . 21.58
0 29.22264 21.6068
1 . 21.9289
0 . 22.3584
0 29.76629 22.6805
1 . 23.1636
0 . 23.5125
0 30.49011 23.5394
1 . 22.9757
0 . 22.1973
0 30.43139 22.1705
1 . 22.0094
0 . 22.1436
0 30.55104 23.5125
1 . 24.1298
0 . 23.9151
0 31.23162 23.7004
1 . 23.5125
0 . 23.4857
0 31.1131 23.1904
1 . 23.1099
0 . 23.0831
0 31.19057 22.8415
1 . 22.8147
0 . 22.4926
0 30.813 22.0631
1 . 22.09
0 . 22.0631
0 31.02251 22.1973
1 . 22.6536
0 . 23.0025
0 31.59918 23.3246
1 . 23.593
0 . 23.8078
0 32.12606 23.7809
1 . 24.2372
0 . 24.613
0 32.77717 24.8277
1 . 24.613
0 . 25.0156
0 33.36753 25.1498
1 . 25.2035
0 . 25.1766
0 33.72706 25.123
1 . 25.3645
0 . 25.3914
0 34.04833 25.5524
1 . 25.5793
0 . 25.6866
0 34.18046 25.6866
1 . 25.8745
0 . 26.1698
0 34.5608 26.3308
1 . 26.5724
0 . 26.8945
0 35.01134 26.975
1 . 26.8676
0 . 26.9213
0 35.69479 27.1897
1 . 27.3776
0 . 27.5118
0 35.94954 27.4581
1 . 27.6997
0 . 27.8876
0 36.72708 27.8876
1 . 28.3439
0 . 28.5049
0 37.16382 28.5854
1 . 28.7733
0 . 28.9612
0 37.66862 29.0686
1 . 28.6659
0 . 29.5517
0 37.80219 29.9006
1 . 30.2227
0 . 30.4106
0 38.73452 30.8132
1 . 30.9474
0 . 31.189
0 39.26406 31.4305
1 . 31.7258
0 . 31.86
0 40.06152 31.9405
1 . 32.2626
0 . 32.3968
0 41.00631 32.7994
1 . 33.1215
0 . 33.3363
0 42.01891 33.7925
1 . 33.8462
0 . 34.1683
0 42.19097 34.3293
1 . 34.5172
0 . 34.5441
0 42.49152 34.8662
1 . 35.1077
0 . 34.8661
0 42.85582 34.9467
1 . 35.1115
0 . 34.7133
0 43.24926 34.5176
1 . 34.8432
0 . 34.5392
0 43.2872 34.5349
1 . 34.4562
0 . 35.1164
0 43.66088 35.0594
1 . 35.3449
0 . 35.8504
0 44.01233 36.2365
1 . 36.1975
0 . 36.3272
0 44.90609 36.4406
1 . 36.4934
0 . 36.9027
0 45.66442 37.0383
1 . 36.9815
0 . 37.0847
0 45.99332 37.2251
1 . 37.299
0 . 37.7815
0 46.19803 37.9008
1 . 38.1301
0 . 38.3741
0 46.91637 38.675
1 . 38.5327
0 . 38.3871
0 47.06684 38.7621
0 . 38.9667
1 . 39.0563
0 . 39.0475
0 47.36143 39.0589
1 . 38.6908
0 . 38.5869
0 47.15469 37.8724
1 . 37.8474
0 . 37.7983
0 47.07112 37.7011
1 . 37.6572
0 . 37.5354
0 47.15441 37.6275
1 . 37.5604
0 . 37.3015
0 47.57213 36.5553
1 . 36.3339
0 . 37.1684
0 47.08281 37.4543
1 . 37.3829
0 . 37.3424
0 48.34349 37.5521
1 . 37.7426
0 . 37.9009
0 48.61938 37.7909
1 . 37.5716
0 . 38.1822
0 48.9995 38.468
1 . 38.6313
0 . 39.0772
0 49.14261 40.0157
1 . 40.3955
0 . 40.694
0 50.02436 41.1164
1 . 41.0952
0 . 41.2034
0 51.18278 41.1879
1 . 41.7352
0 . 42.0547
0 51.65448 42.6321
1 . 43.1184
0 . 43.6139
0 52.51226 43.9001
1 . 44.563
0 . 44.5844
0 53.80502 44.5103
1 . 44.7949
0 . 44.8241
0 54.41504 45.016
1 . 44.9347
0 . 45.344
0 54.11935 45.6563
1 . 45.8834
0 . 45.7719
0 54.62397 45.4415
1 . 45.3088
0 . 45.3135
0 54.17024 45.186
1 . 45.5153
0 . 45.472
0 54.31265 45.4708
1 . 45.0331
0 . 45.0658
0 53.78679 44.8969
1 . 43.4159
0 . 41.8924
0 53.57166 41.3111
1 . 40.3562
0 . 39.9284
0 52.92444 39.9825
1 . 39.8893
0 . 40.1595
0 53.3322 40.5909
1 . 40.9584
0 . 41.4732
0 54.21357 41.6418
1 . 41.7507
0 . 42.2684
0 54.94446 42.885
1 . 43.2957
0 . 43.3395
0 56.1852 43.5878
1 . 43.7862
0 . 43.7843
0 56.60972 44.0423
1 . 44.3471
0 . 44.4774
0 56.89756 44.4925
1 . 45.1442
0 . 45.6135
0 57.32462 45.3646
1 . 46.055
0 . 46.6286
0 57.9916 47.0508
1 . 47.4509
0 . 47.8008
0 59.12977 47.8822
1 . 47.8922
0 . 48.1184
0 60.17586 48.2307
1 . 48.2623
0 . 48.3303
0 60.18218 47.672
1 . 47.9164
0 . 48.8192
0 60.39158 49.8393
1 . 50.0106
0 . 50.3556
0 62.73963 50.3372
1 . 50.5218
0 . 50.6636
0 63.35317 51.0728
1 . 51.445
0 . 51.7376
0 64.20288 51.3926
1 . 51.6837
0 . 51.8569
0 64.33044 51.2945
1 . 51.6919
0 . 51.685
0 64.40832 51.6005
1 . 51.2595
0 . 51.3229
0 64.8708 51.595
1 . 51.5496
0 . 51.599
0 65.03874 51.8227
1 . 51.8523
0 . 51.6869
0 65.24912 50.6413
1 . 49.4133
0 . 48.8003
0 63.92578 48.4819
1 . 48.6125
0 . 49.4073
0 63.82892 50.0203
1 . 50.8923
0 . 51.1886
0 65.01184 50.9085
1 . 50.6585
0 . 50.9285
0 66.35726 50.7029
1 . 51.0228
0 . 51.2552
0 65.87269 51.5854
1 . 51.5768
0 . 51.2536
0 66.62858 50.8998
1 . 50.3323
0 . 49.7768
0 65.85127 48.8027
1 . 49.7531
0 . 49.384
0 64.74973 48.9496
1 . 48.6488
0 . 48.4896
0 65.10247 48.3322
1 . 47.9335
0 . 47.7816
0 64.868 47.3564
1 . 47.1725
0 . 46.8316
0 64.93128 47.7196
1 . 47.431
0 . 47.814
0 65.78175 48.3951
1 . 48.7317
0 . 49.0093
0 67.28287 49.7543
1 . 50.3086
0 . 51.0787
0 68.60022 51.4926
1 . 51.6677
0 . 51.9253
0 70.01489 52.9632
1 . 53.2164
0 . 53.4651
0 71.40597 53.8086
1 . 54.0599
0 . 54.2482
0 72.6601 54.4279
1 . 54.4617
0 . 54.3773
0 73.37493 54.306
1 . 54.5139
0 . 54.5713
0 73.96019 54.4371
1 . 54.6664
0 . 54.7455
0 74.69545 54.6042
1 . 54.6782
0 . 54.7159
0 75.37928 54.339
1 . 54.5707
0 . 54.8135
0 76.55196 54.5916
1 . 54.7719
0 . 55.3412
0 77.12624 55.6062
1 . 55.2091
0 . 54.8519
0 77.84109 54.8839
1 . 54.9927
0 . 54.8165
0 78.19843 55.1675
1 . 55.0457
0 . 55.1503
0 78.98555 55.3968
1 . 55.6593
0 . 56.1333
0 79.3945 55.9679
1 . 56.6775
0 . 56.7642
0 79.94965 57.1169
1 . 57.4935
0 . 57.7707
0 80.8471 58.1523
1 . 58.6196
0 . 58.7737
0 81.58035 59.6354
1 . 59.9604
0 . 60.2533
0 82.92687 60.2832
1 . 60.5286
0 . 60.6669
0 83.39324 60.9879
1 . 60.918
0 . 61.0765
0 84.4951 61.1063
1 . 61.3905
0 . 61.2132
0 84.98282 61.5021
1 . 61.6122
0 . 61.8936
0 86.1085 62.0714
1 . 61.806
0 . 61.961
0 86.97711 62.0166
1 . 61.5631
0 . 61.6029
0 87.66105 61.0102
1 . 61.5621
0 . 61.3843
0 88.31544 61.3103
1 . 61.5146
0 . 61.8768
0 88.5023 61.4882
1 . 62.0678
0 . 62.3988
0 89.47129 62.3357
1 . 62.4364
0 . 62.6392
0 89.81727 62.5683
1 . 62.7314
0 . 62.8608
0 89.83945 62.3779
1 . 61.637
0 . 61.2198
0 89.07363 60.9412
1 . 60.5393
0 . 60.2144
0 88.65564 60.3452
1 . 60.9449
0 . 61.5109
0 89.34366 61.5154
1 . 61.5997
0 . 62.1313
0 89.77252 61.9921
1 . 61.9329
0 . 61.6968
0 90.16444 61.3162
0 . 61.7625
1 . 62.3018
0 . 62.735
0 91.2295 62.9477
1 . 62.9333
0 . 63.4966
0 92.23545 63.1933
1 . 63.3374
0 . 63.8251
0 93.13208 64.0929
1 . 64.1359
0 . 64.442
0 94.06528 64.6798
1 . 64.65
0 . 64.8439
0 94.24065 64.6069
1 . 64.7218
0 . 64.9088
0 94.80106 64.8689
1 . 65.1755
0 . 65.6744
0 95.26337 65.9414
1 . 66.2823
0 . 66.5527
0 96.53509 66.5732
1 . 67.2551
0 . 67.6129
0 97.48156 67.9941
1 . 68.4527
0 . 68.5674
0 98.81384 68.9525
1 . 69.1966
0 . 69.7795
0 99.39655 70.2111
1 . 70.9325
0 . 71.0773
0 100.52518 71.0101
1 . 71.1135
0 . 71.0925
0 100.86878 71.3036
1 . 71.5868
0 . 71.2946
0 101.22122 72.246
1 . 72.5149
0 . 72.4092
0 102.08772 72.5899
1 . 72.8672
0 . 72.3857
0 102.81246 73.5162
1 . 73.4143
0 . 74.0513
0 103.48691 74.5812
1 . 75.2056
0 . 75.0578
0 105.29379 75.5237
1 . 76.0082
0 . 75.9507
0 106.26778 76.6062
1 . 77.0862
0 . 77.2068
0 107.39057 78.1421
1 . 78.6905
0 . 78.7482
0 108.20908 79.2425
1 . 79.634
0 . 80.3148
0 109.8415 81.0985
1 . 81.8177
0 . 82.55
0 111.24013 83.2814
1 . 83.5471
0 . 83.9719
0 112.10329 84.0422
1 . 84.1094
0 . 84.402
0 113.21246 84.9233
1 . 84.3698
0 . 84.0508
0 114.31046 85.7994
1 . 85.5797
0 . 86.241
0 115.80587 86.206
1 . 86.5085
0 . 86.9117
0 117.70686 87.3052
1 . 87.4728
0 . 87.6419
0 118.64675 88.3165
1 . 88.1778
0 . 88.737
0 119.62524 89.0973
1 . 88.7815
0 . 89.9689
0 121.13075 90.4104
1 . 91.1008
0 . 91.1343
0 123.23336 91.4065
1 . 91.7982
0 . 92.472
0 123.59095 92.671
1 . 92.7438
0 . 92.6345
0 125.9253 92.3191
1 . 92.6699
0 . 92.3486
0 126.07676 92.3421
1 . 92.067
0 . 91.3956
0 126.79338 90.8272
1 . 90.5589
0 . 90.2884
0 126.43283 89.6315
1 . 89.0366
0 . 88.562
0 127.10303 88.3842
1 . 88.0735
0 . 87.6361
0 126.70106 87.1612
1 . 87.1764
0 . 87.7152
0 127.05269 87.7275
1 . 88.4132
0 . 88.8118
0 128.22258 89.1944
1 . 90.0487
0 . 89.8366
0 128.93002 89.8543
1 . 89.9448
0 . 89.663
0 129.55769 90.1208
1 . 89.6894
0 . 90.2943
0 129.64016 90.5477
1 . 90.3587
0 . 89.6553
0 130.31169 89.6978
1 . 89.7318
0 . 90.2652
0 131.52089 90.0358
1 . 90.5492
0 . 90.6137
0 133.72357 91.3041
1 . 91.2014
0 . 91.4431
0 135.2871 91.9245
1 . 91.4496
0 . 91.7958
0 136.06509 92.4943
1 . 91.7493
0 . 92.4549
0 137.06247 92.4832
1 . 92.5476
0 . 93.4371
0 138.30828 93.6306
1 . 94.2703
0 . 94.7136
0 139.50376 95.3245
1 . 95.2402
0 . 95.3681
0 140.99081 95.5331
1 . 95.912
0 . 95.7242
0 141.72695 95.8708
1 . 93.9661
0 . 95.1806
0 142.91757 96.1177
1 . 96.669
0 . 96.7856
0 143.73438 96.8261
1 . 97.0742
0 . 97.44
0 145.46119 97.3002
1 . 97.6752
0 . 97.687
0 145.89585 98.0138
1 . 97.8423
0 . 97.806
0 146.02633 97.6811
1 . 98.6347
0 . 98.1696
0 147.1693 99.2354
1 . 99.3706
0 . 100.092
0 147.26022 100.1357
1 . 100.1295
0 . 100.1757
0 148.38664 100.3027
1 . 100.6868
0 . 100.1968
0 149.38467 100.7645
1 . 100.7407
0 . 100.4921
0 149.91784 100.2213
1 . 99.9541
0 . 99.2345
0 148.8945 98.7761
1 . 98.579
0 . 98.0964
0 149.63357 96.5934
1 . 92.5289
0 . 93.3148
0 148.91643 92.121
1 . 89.5075
0 . 87.5382
0 145.76985 86.9117
1 . 85.6157
0 . 84.9483
0 143.75018 84.0497
1 . 83.732
0 . 84.567
0 143.55558 85.3735
1 . 85.9988
0 . 86.3075
0 144.02477 86.6403
1 . 86.93
0 . 87.99
0 145.41901 88.2232
1 . 88.8923
0 . 89.2429
0 146.04845 90.6351
1 . 90.8407
0 . 91.4132
0 147.45933 91.673
1 . 91.9146
0 . 91.6296
0 148.45458 91.8108
1 . 92.5893
0 . 92.6124
0 149.39001 92.1015
1 . 93.0194
0 . 92.5816
0 148.81301 92.8754
1 . 93.0939
0 . 93.6897
0 149.89555 94.1465
1 . 94.2426
0 . 94.7279
0 150.21149 94.8324
1 . 95.1997
0 . 96.015
0 151.90255 96.375
1 . 96.0067
0 . 96.7966
0 152.75047 97.1123
1 . 97.1618
0 . 97.7061
0 153.36735 97.1146
1 . 97.3865
0 . 97.3111
0 154.31335 98.2597
1 . 98.3571
0 . 98.4084
0 154.33702 99.0438
1 . 99.488
0 . 99.3112
0 155.38441 99.4162
1 . 99.6083
0 . 99.4432
0 156.06591 99.9987
1 . 100.7177
0 . 100.819
0 157.79938 101.375
1 . 101.5572
0 . 101.3061
0 159.16208 102.2567
1 . 103.1059
0 . 103.1885
0 158.31652 103.6839
1 . 104.105
0 . 104.4671
0 160.10405 104.3507
0 . 105.2863
1 . 105.2619
0 . 106.6291
0 161.50614 106.5114
;
proc print data=useco(obs=8) noobs;
var date startQ gdp indpro;
run;
proc ssm data=useco opt(maxiter=100);
id date interval=month;
/* Bivariate integrated random walk */
state irwState(2) type=ll(slopecov(g));
comp irwInd = irwState[1];
comp irwGdp = irwState[2];
/* Bivariate cycle */
state cycle(2) type=cycle cov(g);
comp cycInd = cycle[1];
comp cycGdp = cycle[2];
/* Bivariate white noise */
state noise(2) type=wn cov(g);
comp noiseInd = noise[1];
comp noiseGdp = noise[2];
/* Observation equations */
model indpro = irwInd cycInd noiseInd;
model gdp = irwGdp cycGdp noiseGdp / distribute(start=startQ);
/* Components for output */
eval trendCycGdp = irwGdp + cycGdp;
eval trendCycInd = irwInd + cycInd;
eval monthlyGdp = irwGdp + cycGdp + noiseGdp;
/* Output data set */
output out=forGdp pdv press;
run;
proc sgplot data=forGdp;
title "Smoothed estimate of the monthly GDP";
series x=date y=smoothed_monthlyGDP;
run;
proc sgplot data=forGdp;
title "Smoothed trend cycle of the monthly GDP";
where year(date) >= 1950 & year(date) < 1960;
series x=date y=smoothed_trendCycGdp;
run;
title;