X13 Procedure

Example 45.9 Creating an MDLINFO= Data Set for Use with the PICKMDL Statement

(View the complete code for this example.)

This example illustrates how you can create a data set for use in the PICKMDL statement that contains five commonly used ARIMA models:

  • ARIMA (0 1 1)(0 1 1)s

  • ARIMA (0 1 2)(0 1 1)s

  • ARIMA (2 1 0)(0 1 1)s

  • ARIMA (0 2 2)(0 1 1)s

  • ARIMA (2 1 2)(0 1 1)s

The following macro code creates a MDLINFOIN= data set for a general ARIMA model:


   %macro makemodel(name,p,d,q,sp,sd,sq,model);
      data "&name" (keep= _MODELTYPE_ _MODELPART_ _COMPONENT_
                          _DSVAR_ _PARMTYPE_ _FACTOR_ _LAG_
                            _LABEL_ );
         length _MODELTYPE_ _MODELPART_ _COMPONENT_ _DSVAR_
                _PARMTYPE_ $32;
         length _FACTOR_ _LAG_ 8;
         length _LABEL_ $32;

         _MODELTYPE_="ARIMA";
         _MODELPART_="FORECAST";
         _DSVAR_=".";

         _LABEL_="("||"&p"||" "||"&d"||" "||"&q"||")("||
                 "&sp"||" "||"&sd"||" "||"&sq"||")s";

         /* nonseasonal AR factors */
         _COMPONENT_="NONSEASONAL";
         _PARMTYPE_="AR";
         _FACTOR_=1;
         do _LAG_=1 to &p;
            output;
            end;

         /* seasonal AR factors */
         _COMPONENT_="SEASONAL";
         _PARMTYPE_="AR";
         _FACTOR_=2;
         do _LAG_=1 to &sp;
            output;
            end;

         /* nonseasonal MA factors */
         _COMPONENT_="NONSEASONAL";
         _PARMTYPE_="MA";
         _FACTOR_=1;
         do _LAG_=1 to &q;
            output;
            end;

         /* seasonal MA factors */
         _COMPONENT_="SEASONAL";
         _PARMTYPE_="MA";
         _FACTOR_=2;
         do _LAG_=1 to &sq;
            output;
            end;

         /* nonseasonal DIF */
         _COMPONENT_="NONSEASONAL";
         _PARMTYPE_="DIF";
         _FACTOR_=1;
         _LAG_=1;
         do i_=1 to &d;
            output;
            end;

         /* seasonal DIF */
         _COMPONENT_="SEASONAL";
         _PARMTYPE_="DIF";
         _FACTOR_=2;
         _LAG_=1;
         do i_=1 to &sd;
            output;
            end;

      run;
      data sasuser.&name;
        length _MODEL_ $32;
        set "&name";
        _MODEL_ = "&model";
      run;

   %mend makemodel;

The following SAS statements use the macro to generate a data set with some commonly used models for use in the PICKMDL statement:

%makemodel(x13mdl1,0,1,1,0,1,1,Model1);
%makemodel(x13mdl2,0,1,2,0,1,1,Model2);
%makemodel(x13mdl3,2,1,0,0,1,1,Model3);
%makemodel(x13mdl4,0,2,2,0,1,1,Model4);
%makemodel(x13mdl5,2,1,2,0,1,1,Model5);

data Models;
   length _NAME_ $32;
   set sasuser.x13mdl1 sasuser.x13mdl2 sasuser.x13mdl3
       sasuser.x13mdl4 sasuser.x13mdl5;
   _NAME_ = 'sales';
run;

The Models data set is shown in Output 45.9.1.

title '5 Commonly Used Models';
proc print data=Models;
run ;

Output 45.9.1: A Data Set That Contains Models for Use with the PICKMDL Statement

5 Commonly Used Models

Obs_NAME__MODEL__MODELTYPE__MODELPART__COMPONENT__DSVAR__PARMTYPE__FACTOR__LAG__LABEL_
1salesModel1ARIMAFORECASTNONSEASONAL.MA11(0 1 1)(0 1 1)s
2salesModel1ARIMAFORECASTSEASONAL.MA21(0 1 1)(0 1 1)s
3salesModel1ARIMAFORECASTNONSEASONAL.DIF11(0 1 1)(0 1 1)s
4salesModel1ARIMAFORECASTSEASONAL.DIF21(0 1 1)(0 1 1)s
5salesModel2ARIMAFORECASTNONSEASONAL.MA11(0 1 2)(0 1 1)s
6salesModel2ARIMAFORECASTNONSEASONAL.MA12(0 1 2)(0 1 1)s
7salesModel2ARIMAFORECASTSEASONAL.MA21(0 1 2)(0 1 1)s
8salesModel2ARIMAFORECASTNONSEASONAL.DIF11(0 1 2)(0 1 1)s
9salesModel2ARIMAFORECASTSEASONAL.DIF21(0 1 2)(0 1 1)s
10salesModel3ARIMAFORECASTNONSEASONAL.AR11(2 1 0)(0 1 1)s
11salesModel3ARIMAFORECASTNONSEASONAL.AR12(2 1 0)(0 1 1)s
12salesModel3ARIMAFORECASTSEASONAL.MA21(2 1 0)(0 1 1)s
13salesModel3ARIMAFORECASTNONSEASONAL.DIF11(2 1 0)(0 1 1)s
14salesModel3ARIMAFORECASTSEASONAL.DIF21(2 1 0)(0 1 1)s
15salesModel4ARIMAFORECASTNONSEASONAL.MA11(0 2 2)(0 1 1)s
16salesModel4ARIMAFORECASTNONSEASONAL.MA12(0 2 2)(0 1 1)s
17salesModel4ARIMAFORECASTSEASONAL.MA21(0 2 2)(0 1 1)s
18salesModel4ARIMAFORECASTNONSEASONAL.DIF11(0 2 2)(0 1 1)s
19salesModel4ARIMAFORECASTNONSEASONAL.DIF11(0 2 2)(0 1 1)s
20salesModel4ARIMAFORECASTSEASONAL.DIF21(0 2 2)(0 1 1)s
21salesModel5ARIMAFORECASTNONSEASONAL.AR11(2 1 2)(0 1 1)s
22salesModel5ARIMAFORECASTNONSEASONAL.AR12(2 1 2)(0 1 1)s
23salesModel5ARIMAFORECASTNONSEASONAL.MA11(2 1 2)(0 1 1)s
24salesModel5ARIMAFORECASTNONSEASONAL.MA12(2 1 2)(0 1 1)s
25salesModel5ARIMAFORECASTSEASONAL.MA21(2 1 2)(0 1 1)s
26salesModel5ARIMAFORECASTNONSEASONAL.DIF11(2 1 2)(0 1 1)s
27salesModel5ARIMAFORECASTSEASONAL.DIF21(2 1 2)(0 1 1)s


The following statements request that the PICKMDL method be used to choose a model from the list of models that are defined in the Models data set. The default METHOD=FIRST option chooses the first acceptable model. The chosen model is shown in the mdlchosen data set in Output 45.9.2.

proc x13 data=sales date=date mdlinfoin=Models mdlinfoout=mdlchosen;
   var sales;
   transform function=log;
   pickmdl method=first;
run;
title 'Chosen Model';
proc print data=mdlchosen;
run ;

Output 45.9.2: The Model Chosen from the Five Commonly Used Models

Chosen Model

Obs_NAME__MODEL__MODELTYPE__MODELPART__COMPONENT__PARMTYPE__DSVAR__VALUE__FACTOR__LAG__SHIFT__NOEST__EST__STDERR__TVALUE__PVALUE__STATUS__SCORE__LABEL_
1salesMODEL1ARIMAFORECASTTRANSFORMLOGsales.......... (0 1 1)(0 1 1)s
2salesMODEL1ARIMAFORECASTNONSEASONALDIFsales..1....... (0 1 1)(0 1 1)s
3salesMODEL1ARIMAFORECASTSEASONALDIFsales..1....... (0 1 1)(0 1 1)s
4salesMODEL1ARIMAFORECASTNONSEASONALMAsales.11.00.401810.0788705.09458.000001192. (0 1 1)(0 1 1)s
5salesMODEL1ARIMAFORECASTSEASONALMAsales.21.00.556950.0762557.303692.4359E-11. (0 1 1)(0 1 1)s


The following statements reverse the order of the models in the input data set. The default METHOD=FIRST option is used to select the model. The chosen model is shown in the mdlchosen data set in Output 45.9.3. With METHOD=FIRST, a different model is chosen because the order is changed.

data Models;
   length _NAME_ $32;
   set sasuser.x13mdl5 sasuser.x13mdl4 sasuser.x13mdl3
       sasuser.x13mdl2 sasuser.x13mdl1 ;
   _NAME_ = 'sales';
run;

proc x13 data=sales date=date mdlinfoin=Models mdlinfoout=mdlchosen;
   var sales;
   transform function=log;
   pickmdl method=first;
run;
title 'Chosen Model';
proc print data=mdlchosen;
run ;

Output 45.9.3: The Model Chosen from the Five Commonly Used Models, Reversed Order

Chosen Model

Obs_NAME__MODEL__MODELTYPE__MODELPART__COMPONENT__PARMTYPE__DSVAR__VALUE__FACTOR__LAG__SHIFT__NOEST__EST__STDERR__TVALUE__PVALUE__STATUS__SCORE__LABEL_
1salesMODEL3ARIMAFORECASTTRANSFORMLOGsales.......... (2 1 0)(0 1 1)s
2salesMODEL3ARIMAFORECASTNONSEASONALDIFsales..1....... (2 1 0)(0 1 1)s
3salesMODEL3ARIMAFORECASTSEASONALDIFsales..1....... (2 1 0)(0 1 1)s
4salesMODEL3ARIMAFORECASTNONSEASONALARsales.11.0-0.361590.086055-4.201880.00005. (2 1 0)(0 1 1)s
5salesMODEL3ARIMAFORECASTNONSEASONALARsales.12.0-0.063660.086141-0.739050.46120. (2 1 0)(0 1 1)s
6salesMODEL3ARIMAFORECASTSEASONALMAsales.11.00.561090.0728147.705880.00000. (2 1 0)(0 1 1)s


The following example shows the use of PICKMDL statement option METHOD=BEST to select the model. The chosen model is shown in the mdlchosen data set in Output 45.9.4. With METHOD=BEST, a different model is chosen than either of the previous models chosen. Because the order in which the models occur in the MDLINFOIN= data set affects model selection when METHOD=FIRST is specified, it is a common practice to list models from the simplest model to the most complex in the MDLINFOIN= data set that is used in conjunction with the PICKMDL statement.

proc x13 data=sales date=date mdlinfoin=Models mdlinfoout=mdlchosen;
   var sales;
   transform function=log;
   pickmdl method=best;
run;
title 'Chosen Model';
proc print data=mdlchosen;
run ;

Output 45.9.4: The Model Chosen from the Five Commonly Used Models, METHOD=BEST

Chosen Model

Obs_NAME__MODEL__MODELTYPE__MODELPART__COMPONENT__PARMTYPE__DSVAR__VALUE__FACTOR__LAG__SHIFT__NOEST__EST__STDERR__TVALUE__PVALUE__STATUS__SCORE__LABEL_
1salesMODEL2ARIMAFORECASTTRANSFORMLOGsales.......... (0 1 2)(0 1 1)s
2salesMODEL2ARIMAFORECASTNONSEASONALDIFsales..1....... (0 1 2)(0 1 1)s
3salesMODEL2ARIMAFORECASTSEASONALDIFsales..1....... (0 1 2)(0 1 1)s
4salesMODEL2ARIMAFORECASTNONSEASONALMAsales.11.00.396130.0861264.599370.00001. (0 1 2)(0 1 1)s
5salesMODEL2ARIMAFORECASTNONSEASONALMAsales.12.00.039610.0861630.459660.64652. (0 1 2)(0 1 1)s
6salesMODEL2ARIMAFORECASTSEASONALMAsales.21.00.559030.0764467.312770.00000. (0 1 2)(0 1 1)s


Last updated: June 19, 2025