Univariate Time Series Analysis Action Set

Forecasting Time Series Data Using the ARIMA Model

This section contains PROC CAS code.

Note: Input data must be accessible in your CAS session, either as a CAS table or as a transient-scope table. A CAS table has a two-level name: the first level is your CAS engine libref, and the second level is the table name. You refer to this table in the CAS procedure by specifying only the second level. For more information about two-level names, see Chapter 4, Shared Concepts (SAS Econometrics: Econometrics Procedures). A transient-scope table is called directly from the action and exists in memory for the duration of the action. For more information about accessing data, see SAS Viya: System Programming Guide. For more information about PROC CAS and programming in CASL, see SAS Cloud Analytic Services: CASL Programmer’s Guide and SAS Cloud Analytic Services: CASL Reference.

This example illustrates how you can use the arima action to model and forecast the airline passengers time series data.

The following DATA step creates the data table mycas.air in your CAS session from data that were recorded monthly. This DATA step assumes that your CAS engine libref is named mycas, but you can substitute any appropriately defined CAS engine libref.

data mycas.myair;
   set sashelp.air;
   AIR2 = air*air;
run;

The data table, mycas.myair, contains a variable, date (which represents time) and two variables named air and air2 (which represent the monthly number of passengers and their square, respectively). Each value of the date variable is recorded in ascending order.

The following PROC CAS statements use the arima action in the uniTimeSeries action set to specify an ARIMAleft-parenthesis 0 comma 1 comma 1 right-parenthesis times left-parenthesis 0 comma 1 comma 1 right-parenthesis Subscript 12 model without a mean term to the logarithms of the airline passenger numbers, and an ARIMAleft-parenthesis 1 comma 1 comma 0 right-parenthesis times left-parenthesis 1 comma 0 comma 0 right-parenthesis model without a mean term to the squared airline passenger numbers:

proc cas;
   uniTimeSeries.arima /
      table={name='MYAIR'},
      timeId={name='DATE'},
      interval='MONTH',
      outEst={name='ARIEST', replace=true},
      outFor={name='ARIFOR', replace=true},
      series={{name='AIR',
               model={{estimate={q={{factor={1}}, {factor={12}}},
                                 method='ML', diff={1, 12},
                                 noint=true, transform='log'},
                       forecast={{lead=4}}}}
              },
              {name='AIR2',
               model={{estimate={p={{factor=1}},
                                 method='ML', noint=true,
                                 diff={1}, transform='log'},
                       forecast={{lead=6}}}}
               }
             };
   run;
   table.fetch /
      table = {name='ARIFOR',
         where='date>=''01SEP1960''d'};
   run;
 quit;

The table parameter names the input data table to be analyzed. The timeId parameter specifies that the Date variable contains time ID values. The interval parameter specifies a monthly interval at which to accumulate the time series vectors. The outEst parameter specifies the table in which to store the parameter estimates and their standard errors. The outFor parameter specifies the table in which to store the forecasts for the accumulated time series variables.

The series parameter list contains the name parameter (which names the series you want to analyze) and the model parameter list (which the specifies the types of inference tasks you want to perform).

Each model parameter list contains estimate and forecast parameter lists:

  • The estimate parameter list contains several parameters related to estimation tasks. For example, the parameters p (in the first model parameter list), q (in the second model parameter list), and diff specify the AR, MA, and difference orders, respectively, in the ARIMA model, and the parameters method and transform specify the estimation method and type of transform you want to use. Finally the parameter noint specifies a model without an intercept term.

  • The forecast parameter list contains the parameter lead, which specifies the number of steps you want to forecast in the future.

The arima action saves the parameter estimates and the forecasts to output tables whose names are specified in the outEst and outFor parameters. Output 21.1.1 shows a selected part of the ARIFOR table, which is requested in the outFor parameter.

Output 21.1.1: Selected Rows of Forecasts of Sales of Shoes

Results from table.fetch

Selected Rows from Table ARIFOR
_Index_Variable
Name
Forecasting ModelTime ID ValuesActual ValuesPredicted ValuesPrediction ErrorsPrediction Standard
Errors
Upper Confidence
Limits
Lower Confidence
Limits
1AIRarimaModel1_1SEP1960508513.30550748-5.30550748218.998904474551.53524047477.07210737
2AIRarimaModel1_1OCT1960461447.9023334613.09766653916.578146002481.26099875416.28563692
3AIRarimaModel1_1NOV1960390401.01137708-11.0113770814.842577636430.87771915372.70463682
4AIRarimaModel1_1DEC1960432438.8158222-6.81582220116.241828241471.49774646407.8405277
5AIRarimaModel1_1JAN1961.450.73196198.16.682878644484.30137104418.91552657
6AIRarimaModel1_1FEB1961.426.11293231.18.379312587463.25326816391.22240831
7AIRarimaModel1_1MAR1961.479.56635127.23.25334202526.72972214435.60183908
8AIRarimaModel1_1APR1961.493.10515339.26.287883208546.59972273443.58529259
9AIR2arimaModel1_1SEP1960258064371376.01282-113312.012878612.342819547653.5971241037.9033
10AIR2arimaModel1_1OCT1960212521245342.54462-32821.5446251933.75867361796.99939159237.13569
11AIR2arimaModel1_1NOV1960152100208736.58796-56636.5879644185.062161307815.63509135478.40401
12AIR2arimaModel1_1DEC1960186624145146.5410941477.45890630724.412061214041.8944594205.917262
13AIR2arimaModel1_1JAN1961.198945.50943.42112.500671293377.11673129123.60198
14AIR2arimaModel1_1FEB1961.207163.24822.69797.879731373318.37931103240.33161
15AIR2arimaModel1_1MAR1961.214732.59496.94125.387014447280.1991386474.695477
16AIR2arimaModel1_1APR1961.222370.9129.117147.36242518983.9834174581.494746
17AIR2arimaModel1_1MAY1961.230236.89443.139915.82035590379.7332365572.021799
18AIR2arimaModel1_1JUN1961.238371.75984.163024.36956662533.2661758432.662125


Forecasting Time Series Data Using the ARIMA Model

This example is not available for the Lua programming language.

Forecasting Time Series Data Using the ARIMA Model

This example is not available for the Python programming language.

Forecasting Time Series Data Using the ARIMA Model

This example is not available for the R programming language.

Last updated: February 20, 2025