BookmarkSubscribeRSS Feed
sasalex2024
Fluorite | Level 6

Dear All,

 

I am very new to SAS, and I am currently running a dynamic regression model without transfer functions, where the noise term follows a multiplicative seasonal and nonseasonal ARIMA model of the form: ARIMA(1,1,1)(1,1,2,12). (My reference is this source: https://documentation.sas.com/doc/en/etsug/15.2/etsug_arima_gettingstarted25.htm). My dataset is monthly and is attached to this message as an Excel file.

 

In SAS, I am using the following code:

proc arima data=a;
identify var=Yt(1,12) crosscorr=(X1t(1,12) X2t(1,12));
estimate p=(1)(12) q=(1)(12 24) input=(X1t, X2t) method=ml noconstant;
run;

When performing the same procedure in STATA, I use:

gen Date = _n
tsset Date
arima Yt X1t X2t, arima(1,1,1) sarima(1,1,2,12) nocons, if Date<=168

Both SAS and STATA yield nearly identical results for the estimated coefficients, except for the seasonal MA terms. Specifically, STATA reports absolute values of "0.3621697" and "0.780338", whereas SAS computes "0.20275" and "0.66553". This discrepancy suggests a potential error in my SAS code or differences in optimization convergence.

 

Could you please assist in identifying any errors in my SAS code, or suggest additional options to potentially enhance result accuracy?

 

Many thanks.

 

2 REPLIES 2
ballardw
Super User

Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.

 

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the </> icon or attached as text to show exactly what you have and that we can test code against.

 

 

Knowing nothing about STATA I can't provide any response. However I do see what appears to be a limit set on a variable named DATE and there is nothing that we can see in the SAS code that corresponds. So how identical are the input data sets?

sasalex2024
Fluorite | Level 6

Thank you. I followed the instructions in the link you've provided, and I will try to insert my data here. Could you please tell if this is the correct way? In SAS code, my original Excel data set has missing observations past 168th observations, so the regression would only use the 168 observations (this is what I needed anyway). In STATA, I specified with the command to use only the corresponding part of the dataset. Alternatively, only the 1st 168 observations can be inserted into SAS or STATA. P.S. Please note in the code I've inserted earlier data name is "a" (to match the excel file name), but actually I use the name Series which uses that dataset. Below, the first column is Yt, the second column is X1t and the third column is X2t.

 data WORK.SERIES;
   infile datalines dsd truncover;
   input time:MONYY7. Yt:BEST. X1t:BEST. X2t:BEST.;
   format time MONYY7. Yt BEST. X1t BEST. X2t BEST.;
   label time="time" Yt="Yt" X1t="X1t" X2t="X2t";
 datalines;
 JAN1970 4.3107991254 45.144213361 0
 FEB1970 4.1604443639 38.845849199 0
 MAR1970 4.1620032107 35.902646142 0
 APR1970 4.1042948931 25.258661881 3.6055512755
 MAY1970 4.1239033645 16.401219467 6.0827625303
 JUN1970 4.2918283668 7.8102496759 11.575836903
 JUL1970 4.4426512565 4.2426406871 13.37908816
 AUG1970 4.3981460166 3.4641016151 10.770329614
 SEP1970 4.2527717988 14.899664426 7.1414284285
 OCT1970 4.249922794 22.803508502 0
 NOV1970 4.2612704335 32.357379375 0
 DEC1970 4.3643716994 39.648455203 0
 JAN1971 4.4140096805 44.56455991 0
 FEB1971 4.2570301445 38.353617822 0
 MAR1971 4.2863413845 36 0
 APR1971 4.1743872699 24.779023387 0
 MAY1971 4.127134385 18.734993995 0
 JUN1971 4.4414740933 4.582575695 13.892443989
 JUL1971 4.4414740933 5.5677643628 9.3808315196
 AUG1971 4.4964707691 5.8309518948 10.440306509
 SEP1971 4.4127982933 13.564659966 8.8317608663
 OCT1971 4.3618239274 19.773719933 3.1622776602
 NOV1971 4.3694478525 31.527765541 0
 DEC1971 4.453183829 38.781438859 0
 JAN1972 4.5336741843 44.305755834 0
 FEB1972 4.4391156017 40.607881008 0
 MAR1972 4.3919769655 35.185224172 0
 APR1972 4.3320482649 27.622454634 0
 MAY1972 4.4296256135 15.394804318 8.0622577483
 JUN1972 4.5097600012 9.7467943448 9.9498743711
 JUL1972 4.5900565482 6.4807406984 10.723805295
 AUG1972 4.7414478043 8.7749643874 12.529964086
 SEP1972 4.4773368145 15.394804318 3.4641016151
 OCT1972 4.5152454785 26.888659319 0
 NOV1972 4.5464811896 33.015148038 0
 DEC1972 4.6405373298 42.567593308 0
 JAN1973 4.6530075154 40.669398815 0
 FEB1973 4.4942386253 36.823905279 0
 MAR1973 4.5119578043 29.30870178 0
 APR1973 4.4272389775 27.037011669 0
 MAY1973 4.4784725329 19.570385791 0
 JUN1973 4.605170186 4.6904157598 10.440306509
 JUL1973 4.757891273 1.7320508076 13.152946438
 AUG1973 4.8097423517 4 13.03840481
 SEP1973 4.6031681833 14.628738838 5.7445626465
 OCT1973 4.5890408041 19.442222095 3.1622776602
 NOV1973 4.5507140002 31.288975694 0
 DEC1973 4.5767707115 40.938978981 0
 JAN1974 4.6249728133 41.797129088 0
 FEB1974 4.4727809979 38.574603044 0
 MAR1974 4.5075573571 34.510867853 0
 APR1974 4.4224485492 24.351591324 0
 MAY1974 4.4931206822 19.467922334 3.3166247904
 JUN1974 4.5390303835 9.2195444573 7.5498344353
 JUL1974 4.8698394841 0 16.340134638
 AUG1974 4.7113303818 7.3484692283 9.2736184955
 SEP1974 4.5358201079 18.303005218 2.4494897428
 OCT1974 4.5736795189 22.759613353 0
 NOV1974 4.5961294413 31.937438845 0
 DEC1974 4.6624952526 37.788887255 0
 JAN1975 4.7068238397 41.073105556 0
 FEB1975 4.6091622073 38.75564475 0
 MAR1975 4.6061696863 38.392707641 0
 APR1975 4.5570298107 28.618176043 0
 MAY1975 4.5951198501 14.594519519 7.7459666924
 JUN1975 4.7068238397 8.0622577483 11.180339887
 JUL1975 4.9670316566 4.582575695 15.716233646
 AUG1975 4.8790068516 2.8284271247 13.114877049
 SEP1975 4.6308379327 17.204650534 4
 OCT1975 4.6491870714 20.29778313 3.3166247904
 NOV1975 4.635699391 29.83286778 0
 DEC1975 4.7655869074 37.69615365 0
 JAN1976 4.8097423517 41.844951906 0
 FEB1976 4.6765601821 33.882148692 0
 MAR1976 4.7022968967 33.271609519 0
 APR1976 4.5716134025 22.516660498 2.8284271247
 MAY1976 4.5941092386 17.521415468 0
 JUN1976 4.7858236857 4.8989794856 10.535653753
 JUL1976 4.970507503 1 15.684387141
 AUG1976 4.9677277931 5.2915026221 12.727922061
 SEP1976 4.7706846245 15.620499352 5.6568542495
 OCT1976 4.740574823 27.748873851 0
 NOV1976 4.7908195329 36 0
 DEC1976 4.9444954916 43.127717306 0
 JAN1977 4.9670316566 47.391982444 0
 FEB1977 4.7423200241 36.193922142 0
 MAR1977 4.7131273275 29.597297174 0
 APR1977 4.6568134191 20.049937656 4
 MAY1977 4.7484043541 9.8994949366 8.5440037453
 JUN1977 4.8235021803 6.3245553203 9.3273790531
 JUL1977 5.027164596 1 15.033296378
 AUG1977 4.8721392168 8.0622577483 7.7459666924
 SEP1977 4.7841528415 12.449899598 4.7958315233
 OCT1977 4.7570325353 24.269322199 0
 NOV1977 4.801559 32.695565449 0
 DEC1977 4.9243509255 41.255302689 0
 JAN1978 4.9863426015 45.420259797 0
 FEB1978 4.8713732268 41.400483089 0
 MAR1978 4.8162411561 35.0142828 0
 APR1978 4.7518645651 25.53429067 0
 MAY1978 4.7458013157 16.583123952 5.8309518948
 JUN1978 4.8948502611 8.4852813742 9.9498743711
 JUL1978 4.9904325868 3.4641016151 11.401754251
 AUG1978 5.060694494 4.6904157598 11.357816692
 SEP1978 5.0005849582 12.409673646 9.8994949366
 OCT1978 4.8275134171 25.019992006 0
 NOV1978 4.8706066495 34.044089061 0
 DEC1978 4.970507503 41.964270517 0
 JAN1979 5.060694494 47.30750469 0
 FEB1979 4.9670316566 42.402830094 0
 MAR1979 4.8963461477 35.818989377 0
 APR1979 4.8582608137 27.147743921 0
 MAY1979 4.8243057159 18.601075238 4.3588989435
 JUN1979 4.8713732268 5.8309518948 10.246950766
 JUL1979 5.0343518207 0 14.76482306
 AUG1979 5.0594254583 7.1414284285 12.165525061
 SEP1979 4.906015245 11.532562595 7.0710678119
 OCT1979 4.8774847813 24.207436874 0
 NOV1979 4.960043508 32.496153619 0
 DEC1979 5.0066272727 36.083237105 0
 JAN1980 5.0369526024 40.767634221 0
 FEB1980 4.9808631358 39.547439867 0
 MAR1980 4.9579375051 35.846896658 0
 APR1980 4.8410325097 24.269322199 3.4641016151
 MAY1980 4.8226979985 14.933184523 7.8102496759
 JUN1980 4.9387811903 7.5498344353 10.344080433
 JUL1980 5.1834675249 0 15.231546212
 AUG1980 5.0900624277 3.4641016151 12.041594579
 SEP1980 4.97535348 14 6
 OCT1980 4.9315920868 26.739483914 0
 NOV1980 4.9423564533 30.919249667 0
 DEC1980 5.0401940963 39.179076048 0
 JAN1981 5.0682750735 39.293765409 0
 FEB1981 4.97535348 35.846896658 0
 MAR1981 4.9301480432 31.320919527 0
 APR1981 4.873669439 23.194827009 0
 MAY1981 4.8605872979 18.193405399 0
 JUN1981 4.9774231599 6.7823299831 8.1240384046
 JUL1981 5.1901752079 4.7958315233 12.56980509
 AUG1981 5.1521348564 5.3851648071 10
 SEP1981 5.0159544556 15.968719423 3.3166247904
 OCT1981 4.9911126276 25.942243542 0
 NOV1981 4.9842913188 30.6757233 0
 DEC1981 5.0869788607 40.373258476 0
 JAN1982 5.1630702171 45.650848842 0
 FEB1982 5.060694494 38.444765573 0
 MAR1982 5.0086332914 34.856850116 0
 APR1982 4.9781121024 27.910571474 0
 MAY1982 4.9649403348 13.341664064 4.7958315233
 JUN1982 4.9712012249 11.832159566 5.1961524227
 JUL1982 5.208392659 0 15
 AUG1982 5.251225759 7.2111025509 12.165525061
 SEP1982 5.0644919669 13.892443989 6.8556546004
 OCT1982 5.0594254583 22.427661492 0
 NOV1982 5.0581548101 32.32645975 0
 DEC1982 5.1375615877 36.027767069 0
 JAN1983 5.1544469961 39.736632973 0
 FEB1983 5.033700567 35.227829908 0
 MAR1983 5.0882134287 33.090784216 0
 APR1983 4.9897520832 28.792360098 0
 MAY1983 4.9739713097 20.90454496 0
 JUN1983 5.1137933862 9.643650761 10.344080433
 JUL1983 5.4076201014 3 16
 AUG1983 5.4651021842 0 15.524174696
 SEP1983 5.2029071817 15.066519173 8.3666002653
 OCT1983 5.1101789244 24.535688293 2.4494897428
 NOV1983 5.1281219896 31.890437438 0
 DEC1983 5.2933048247 45.683695122 0
 ;;;;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Multiple Linear Regression in SAS

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.

Discussion stats
  • 2 replies
  • 579 views
  • 0 likes
  • 2 in conversation