I need to fit a AR(1) model to the attached data set and out put the RESIDUALS to an excel file for plotting.
Can some one help me with this writing residuals to an excel file step please?
data have;
input ar;
i=_n_;
cards;
-1.703233141
-1.703850657
0.091440462
0.022882462
-0.224949807
1.367217146
2.512797936
0.669231031
-0.150223471
0.759437408
0.435890183
0.242421635
0.766223353
0.673573325
0.589709362
0.619025926
-0.731962503
-0.669309886
-0.277606805
-0.093268198
0.04727051
0.282256656
-1.015885861
-0.962834737
0.612218648
1.357896244
0.589988689
0.637063037
0.974907176
1.004179541
0.589961515
1.547349773
1.730216041
-0.861477052
-2.626268836
-1.779317662
0.061755533
1.534604015
0.526923035
1.614684892
0.173828311
0.488559228
0.719774332
-0.191777895
-1.771017794
-0.058856223
0.679685944
3.269724873
1.091529825
0.971006867
-0.107460208
0.293076027
0.370636623
0.533093946
0.391928966
-0.492171644
0.839278575
-0.425762518
-1.207455241
-1.54961444
-1.641561189
-0.27123277
-0.397213342
0.724231229
-0.157298162
1.066291385
1.128867801
1.609255864
0.086916055
-0.115766379
0.537818057
-0.343593782
-2.467415689
-2.173708286
0.072657043
-0.375419903
0.338660815
1.011734183
-0.158013934
0.239575285
-2.583980999
-2.846387638
-0.603616568
-0.497500862
0.297922
-0.015076177
0.150838215
-0.115385963
-1.732796511
-1.592980786
-1.401058263
-0.969909419
-0.163289582
0.762052852
-1.585677285
-1.418407659
-1.243692625
0.622140761
0.485028199
0.933575088
0.788277596
0.069538939
0.235537624
-0.736203794
0.318672947
1.017047843
0.933484359
0.741096717
1.714004131
1.739542595
-0.033124656
-0.173701443
0.440641251
0.643783836
0.457639771
-0.620456893
-1.37360193
-0.95579669
-0.277869925
0.751280471
-0.062705563
-0.688951776
1.60764724
0.568455209
-0.373085754
-0.942035048
-0.081296576
-1.647495371
0.173496866
2.966331223
2.245816685
2.100557048
-1.077766643
-1.161580974
-0.93895674
1.022260341
1.237106891
0.839522745
0.205026862
0.630623776
0.531449234
-0.714343268
-1.355814622
0.548880834
0.267590847
-1.014296508
-0.098426097
-0.491855559
1.225178831
0.470209127
0.699238472
0.5724062
0.029438365
-0.482742156
-0.723112385
0.989385252
0.989329295
-0.578363002
1.321796813
-0.874560301
-0.631065408
-1.529170029
-2.681906783
-0.119903064
0.004533811
0.730458562
0.578137122
0.236370805
-2.079182525
-0.071340718
-0.303920122
0.613980152
1.371999419
-0.814722568
-1.848830753
-0.130395496
-0.509307917
-0.393216756
-1.421626376
-1.260456909
1.717350204
-0.061588567
1.576699575
0.158695843
0.673967143
-0.01453695
-0.4530414
-0.88008168
-0.474358787
-1.648059003
-0.904919194
-0.5591077
0.733474439
0.940235238
-0.212510383
-0.656917914
0.371847888
-0.844212576
0.333547821
1.619507802
0.369515674
0.804317214
0.89894827
0.77951859
0.981110897
0.314118497
-1.051161227
-2.210462871
-0.657069879
1.492717871
1.553498307
-1.024299473
-2.197860477
-0.925403182
-0.583727976
-0.976836244
-2.19909525
-0.725045734
-1.776861852
1.627229106
2.361392176
1.397083255
0.192149392
-0.552117478
-0.598968735
-1.23673472
-0.602974611
0.787100327
0.536302509
-1.008315127
0.084224151
-1.167576987
-0.405077966
-1.203027374
-1.378858106
-1.698293468
-2.093450717
-1.1818349
-1.247048078
-3.544954943
-1.092977498
-1.298717529
0.906210929
0.800989891
2.236083499
-0.362437186
0.422974814
0.588826273
-0.336866824
1.204007401
0.677138821
-1.331655364
-2.241190093
0.184259721
1.930920361
2.311793146
1.109200185
-0.791974638
-1.08564213
1.607991439
1.011779543
-0.094338971
-1.928330832
-3.106928547
-0.091950645
1.495767441
1.683371251
2.346405952
1.89038747
-0.46201662
-0.542984672
0.602729159
0.36527735
1.262175791
0.162724826
-2.066036176
0.243493142
1.731903261
-0.415348157
-0.389712366
0.007746851
-0.268180566
-0.464236965
-1.806022722
-1.310659139
0.391443028
0.55421646
0.464512184
-0.431567189
-1.541712974
-1.406008525
-2.755092752
-2.200624179
-1.43483199
0.704004341
0.185227002
0.939864088
0.232468301
-0.773638109
1.113680641
0.705881922
-0.714587966
-2.015997007
-0.807841071
-0.552233873
-0.805833024
-1.050298585
2.041769753
3.492041813
0.166761303
0.302023916
-1.568907022
-1.774899356
-2.006743891
-2.083914682
0.321201287
-0.005636432
-0.444885535
-0.906073134
1.158743314
1.194715332
0.777231062
-1.625914092
-2.959616502
-1.547453664
0.237328828
-0.061896927
-1.014056666
-0.59835862
-1.77473216
-1.461187464
-0.312216045
-1.371742185
-0.148572264
-0.501180413
0.173015441
-0.062940728
1.320793115
1.617685141
0.413626948
-0.304411351
-0.120355904
0.965082051
0.009849071
2.026863315
1.646435429
-0.380605304
-0.165769236
0.60243475
0.70210055
-0.585501567
-0.663213955
-0.557129177
-0.468884536
-0.442566792
0.485117227
-1.253108375
1.404758252
0.129529169
-0.999482169
0.529962734
-0.182542511
0.500887528
1.050330058
3.047949942
1.846735789
0.438194217
0.774039271
2.380831831
0.714461788
-0.991705441
-1.812732618
-0.31411008
-0.64944534
-1.258499416
-0.915516218
-0.271856335
-1.911122908
-1.291926834
-1.767002829
-0.391157141
-1.024920688
-2.589483443
0.198653089
0.448796084
-1.392323862
-0.880774034
0.104594641
0.824904778
0.479992249
-0.085901242
0.91284545
-0.770693108
1.506673497
-1.179183132
-0.999483257
0.104652556
0.200867468
-0.419183962
1.493706233
0.790044333
0.376065424
1.399303856
0.587585705
-0.44743918
-0.454349503
-0.275231988
-1.241886252
-0.54750486
-0.282745587
1.22568246
-1.497636619
-1.32345921
-0.742289702
-2.699060814
-1.051398766
-1.410396453
-0.921759574
0.500252211
-0.810993728
-0.348990116
1.368846573
-0.133754853
2.271797928
0.694942069
0.337811568
-0.499364258
-0.12218939
-0.261627236
0.806883033
-0.209998381
0.831548748
0.317192399
-0.151603793
0.229057983
1.544714194
0.705456536
0.554796121
-0.164542602
1.340979979
0.27013942
-1.635102833
-0.571436879
-1.829335436
0.286513495
0.060524518
0.283567358
1.545713755
0.419145283
0.631324685
-0.771673491
0.360090947
-0.550902449
-0.791437388
-1.114134223
0.426264571
-0.300942025
1.28479551
-0.201906968
-2.1698603
-0.763315024
0.561826226
-0.233745234
-0.093263909
-0.048754834
-1.202850944
-2.780207782
-1.773726667
-1.169196279
-1.926808303
0.798141217
-1.916343444
-2.435401211
-1.525288907
-0.494366929
0.647918229
0.73818663
-0.08780999
0.494788154
2.442941919
0.839549054
-1.272061449
0.904141233
-1.904132959
-1.729758415
-1.776267913
-2.169291806
-2.297256362
-0.53306235
0.490982244
0.791824657
1.459281082
-0.054616456
-0.359706556
-0.144130081
-0.923044826
-2.523280678
-2.882883854
-1.786493173
-0.111820397
0.84120808
1.53546941
-0.483527434
-0.489710706
1.703309964
0.945793987
0.424951757
-0.778086661
0.507712855
-0.427705531
1.023315002
2.142572142
1.351279261
0.747828058
0.177526009
0.077684339
0.29094858
0.093171908
0.219146046
1.18602888
0.449315792
0.911844076
2.523371914
0.82965641
-0.212184145
0.265989756
-1.576975336
-1.262854119
-1.0576732
0.032535466
-0.806127533
1.087518257
-0.390026142
0.23994921
0.642031813
-0.092846882
-0.022142393
1.435825384
0.377281555
-0.676019356
0.647964027
-0.459169595
-2.258486877
-3.846413176
-1.03565261
-2.139354005
-3.097029764
-2.857969316
-2.802317572
-0.605923201
-0.572358519
-0.854400952
-1.276206431
-1.616642367
-1.805612612
-0.821497021
0.430490664
1.444210812
0.512463713
0.432976074
-0.004116495
1.446708412
0.006330164
0.294152112
0.523739919
0.791703034
0.347739544
-0.579369455
0.131745396
-0.601044398
-1.575871606
-1.0625899
-0.441181866
0.569096116
-0.268895279
-0.704016338
0.857445835
-0.303369363
0.249254948
0.853137327
2.018482976
0.326340389
0.603675756
-2.032820315
-1.318561645
-1.070525997
-0.613038816
-2.315693533
-0.319707816
-0.455340316
0.477791853
-0.222339285
-0.591105311
-1.477556892
-1.116388942
0.781269276
-0.413368571
0.323735684
-1.016287902
0.787329476
0.009812545
2.627247402
1.624402027
0.875536815
0.198283053
-1.02804807
1.177035215
3.279408104
2.637042077
1.004018397
0.413187336
-0.322618191
-0.102609688
-0.066468288
0.670523431
1.732973963
1.43457463
1.258553795
0.566980784
1.295704521
1.008934004
2.124811289
-0.353772447
-0.224305266
1.903396872
1.020991231
2.745426738
1.866075475
0.912030299
0.546062698
-0.465859546
-2.615649423
-0.333521219
-0.161382514
-1.25793969
-1.600986607
1.218107365
0.994386829
-0.03749181
2.780473543
2.348185251
3.396985106
1.265746757
-0.592893626
0.68208655
0.817035399
0.228205488
0.199610576
-0.787236225
0.516510758
0.074959376
0.551352643
0.858844294
-0.54286223
-1.8812778
-0.609824488
-0.90353558
-0.800512887
-0.046958199
-0.708947799
-1.808564699
-1.498610564
-0.141525712
-0.702017354
0.136052747
-0.651297207
0.00725727
-0.446444564
0.128742257
-0.202727822
-1.080402149
-0.258480456
0.779876286
0.526460757
1.937161438
0.444082486
-1.789071415
-0.061286455
0.314832954
1.91249016
0.946714999
-0.337655897
-0.77658777
0.38667357
-0.308544342
-0.752366159
1.323908431
0.532311542
0.187344601
-0.748438977
-1.119948885
0.657197252
1.706374653
0.850581557
1.276079066
0.463038209
0.143438031
-0.211696496
-0.307528028
1.025338791
0.322346751
-2.446036742
-2.835372424
-1.692434656
-2.372605056
-1.581154377
-0.114131448
-0.254987871
-1.727749693
-2.220071323
0.171576056
-0.601633671
0.003036179
0.167370514
-1.403631277
-0.424156178
0.407621063
-0.019708837
-0.020534277
-1.055446499
-1.903050417
0.05588195
0.472787452
0.25333176
0.460258792
0.176142292
-1.901514346
0.895017423
-1.311799499
-1.534454147
-0.568706536
0.027726273
0.078868101
-0.36176327
-0.212113731
0.891889134
-0.654241962
-0.772683008
-2.151932437
-1.073949767
-2.213492052
-0.787207651
-0.546355251
-0.01664553
-0.359662154
-0.289378286
-1.42351752
-2.729965572
-1.572265449
0.0633524
-1.078185336
-1.625986028
-2.121553082
-1.25899818
0.368285546
2.154017322
-0.006309629
1.00871734
1.881835254
0.79666723
1.272574065
0.421689863
0.227800011
1.680619044
1.694901826
-0.642635177
-1.802705932
-1.170164634
-2.339469297
-1.896363617
1.411603907
1.349879621
-0.813043952
-2.518939354
-2.128260717
-1.073169423
0.086409574
1.171839549
0.122476732
-0.658564067
-0.381597911
-0.883972548
-0.265679028
-1.347483667
-0.302503272
0.502296744
1.213052769
2.356581793
0.684726023
0.230133972
0.028201738
0.345406328
0.510971281
-0.523218249
1.008925405
1.634181192
1.699309674
1.20360065
1.76302193
-0.354031663
1.531969991
0.348317166
-1.370224157
-1.566432533
-0.497490709
1.400243671
1.961763668
1.048566542
0.60150767
0.316668128
0.211187799
1.013126244
3.278861747
0.222995251
0.076025269
-0.879239314
-0.532042965
-0.112867199
-1.105592151
0.268047884
0.548791714
0.658795958
-0.84636307
-1.868203866
0.512840297
-0.214583369
0.732722162
-0.076786357
-0.724437049
-0.611197495
0.259804052
-0.433211778
-2.09587017
-0.178208642
0.163117194
-1.350474758
-1.657902624
-0.532721429
-0.353796282
-0.335818986
-1.419651667
-1.011340271
-0.344794941
0.274774603
-0.451610732
-0.47018028
-0.08677203
-0.797121628
-0.125112035
1.258875426
2.288296555
0.600061715
0.341394655
1.398991813
2.413507929
0.627215886
0.106964459
-1.566159674
-0.737681701
-1.879033497
-2.731023466
-1.910367649
-1.212584476
-2.605262345
-1.123155746
1.680149826
2.623306503
1.733784681
1.682015602
0.178976589
0.828821229
-0.131652061
-2.398287506
-1.887145279
-1.591108562
-0.60114794
-1.268214397
-0.723626093
-0.727599428
-0.692625639
-0.229393052
-2.215957108
-1.617688747
0.841156825
-0.239381631
-2.403720702
-1.345598957
-0.100882014
0.31246694
0.159834357
0.528263873
-0.272162148
0.908264948
-0.713042299
-0.146195476
-1.247922326
-1.132410857
-0.531058382
-0.729990239
-1.422574028
2.028460338
0.739759149
-0.143274668
0.051202795
-0.006169156
0.364017203
-0.636566657
0.875010843
-0.680184452
0.821683149
0.155056631
-0.080160643
-0.988727654
0.486830123
1.890638186
1.017438622
-0.723179744
-1.38879166
1.008877003
1.041034374
-1.30116503
-0.87181454
0.999164831
-0.081475743
0.161428186
-0.16825921
1.596978276
1.388488299
-0.856242014
0.242278146
-0.281505643
0.887655405
1.642655771
1.238461556
-0.747157397
-0.557633869
-0.011679166
0.069909113
-0.811212607
-1.065810433
-0.859770578
-1.631517634
-1.923401419
-0.655575151
-2.33294895
-0.575916946
-0.125594946
-0.252088319
-1.164765568
-0.539233534
1.726405418
-0.181177025
2.603062891
2.111718656
1.329988036
-0.024842977
-0.278186805
-0.207653587
-0.164695566
-3.396457823
-3.500308469
-2.149867681
-0.976943982
-1.243429489
0.075316396
1.062966307
0.323823434
0.84395791
1.129555031
1.228139926
1.243521791
0.113778895
0.714317526
0.566813465
-0.734423548
1.697551258
2.111181943
1.628494325
-0.08886197
2.229940274
1.095423802
-1.269850982
0.212139503
0.813363764
2.074538017
-0.379978441
0.582723039
1.007738264
-1.343523263
-1.281435722
-1.709919199
-2.221110283
-0.357830805
-0.957889455
-0.828228651
-2.21342328
-1.741858015
-0.4136128
1.152547859
0.767231874
;
run;
proc arima data=work.have plot=residual(smooth);
identify var=AR nlag=1 noprint;
estimate p=1;
forecast id=I interval=1 align=BEGINNING lead=0 alpha=0.05 out=want;
quit;
Once you created WANT you can export it to EXCEL in many different ways - the easiest might be to right click the data set in the explorer window:
Thanks,
Udo
You could also use PROC GPLOT and skip Excel
Very true - in fact ARIMA does create the plot you are looking for out-of-the-box:
proc arima data=work.have plot=residual(smooth);
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.